Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <hujun5@xiaomi.com>
hujun260 committed Oct 31, 2024
1 parent 97ebf26 commit e5d9392
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
@@ -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)
{
@@ -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))

0 comments on commit e5d9392

Please sign in to comment.