mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 09:38:37 +08:00
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:
@@ -372,7 +372,7 @@ void pthread_mutex_inconsistent(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
DEBUGASSERT(tcb != NULL);
|
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 */
|
/* 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);
|
mutex_unlock(&mutex->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&tcb->mhead_lock, flags);
|
spin_unlock_irqrestore_nopreempt(&tcb->mhead_lock, flags);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user