sched/pthread: use spin_lock_irqsave_nopreempt for mutex head lock

Replace spin_lock_irqsave with spin_lock_irqsave_nopreempt in
pthread_mutex_inconsistent to prevent preemption during mutex list
manipulation and avoid potential deadlocks or race conditions.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2025-06-05 21:11:42 +08:00
committed by Xiang Xiao
parent f7dc54e869
commit bc3d478749
+2 -2
View File
@@ -372,7 +372,7 @@ void pthread_mutex_inconsistent(FAR struct tcb_s *tcb)
DEBUGASSERT(tcb != NULL);
flags = spin_lock_irqsave(&tcb->mhead_lock);
flags = spin_lock_irqsave_nopreempt(&tcb->mhead_lock);
/* Remove and process each mutex held by this task */
@@ -390,5 +390,5 @@ void pthread_mutex_inconsistent(FAR struct tcb_s *tcb)
mutex_unlock(&mutex->mutex);
}
spin_unlock_irqrestore(&tcb->mhead_lock, flags);
spin_unlock_irqrestore_nopreempt(&tcb->mhead_lock, flags);
}