Skip to content

Commit

Permalink
spinlock: add sched_lock to spin_lock_irqsave_wo_note
Browse files Browse the repository at this point in the history
reason:
 We aim to replace big locks with smaller ones. So we will use spin_lock_irqsave extensively to
  replace enter_critical_section in the subsequent process. We imitate the implementation of Linux
  by adding sched_lock to spin_lock_irqsave in order to address scenarios where sem_post occurs
  within spin_lock_irqsave, which can lead to spinlock failures and deadlocks.

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Oct 31, 2024
1 parent 97ebf26 commit 2d48282
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nuttx/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ irqstate_t spin_lock_irqsave_wo_note(FAR volatile spinlock_t *lock)
{
irqstate_t ret;
ret = up_irq_save();
sched_lock_wo_note();

if (NULL == lock)
{
Expand Down Expand Up @@ -714,6 +715,7 @@ void spin_unlock_irqrestore_wo_note(FAR volatile spinlock_t *lock,
}

up_irq_restore(flags);
sched_unlock_wo_note();
}
#else
# define spin_unlock_irqrestore_wo_note(l, f) ((void)(l), up_irq_restore(f))
Expand Down

0 comments on commit 2d48282

Please sign in to comment.