This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a04f257d4bfe5fb6f224b2746c68fb9329d6eca9 Author: wangchengdong <[email protected]> AuthorDate: Thu Oct 30 19:51:48 2025 +0800 sched/wqueue: Replace spinlock/sched_lock with spin_lock_irqsave_nopreempt Replace the spinlock/sched_lock pair in the sched wqueue module with spin_lock_irqsave_nopreempt() to improve code clarity and consistency. Signed-off-by: Chengdong Wang [email protected] --- sched/wqueue/kwork_notifier.c | 6 ++---- sched/wqueue/kwork_thread.c | 12 ++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/sched/wqueue/kwork_notifier.c b/sched/wqueue/kwork_notifier.c index 813b46c0a55..8b3a3b5df40 100644 --- a/sched/wqueue/kwork_notifier.c +++ b/sched/wqueue/kwork_notifier.c @@ -360,8 +360,7 @@ void work_notifier_signal(enum work_evtype_e evtype, * the notifications have been sent. */ - flags = spin_lock_irqsave(&g_notifier_lock); - sched_lock(); + flags = spin_lock_irqsave_nopreempt(&g_notifier_lock); /* Process the notification at the head of the pending list until the * pending list is empty @@ -404,8 +403,7 @@ void work_notifier_signal(enum work_evtype_e evtype, } } - spin_unlock_irqrestore(&g_notifier_lock, flags); - sched_unlock(); + spin_unlock_irqrestore_nopreempt(&g_notifier_lock, flags); } #endif /* CONFIG_WQUEUE_NOTIFIER */ diff --git a/sched/wqueue/kwork_thread.c b/sched/wqueue/kwork_thread.c index 3d5008308a4..725461d76d2 100644 --- a/sched/wqueue/kwork_thread.c +++ b/sched/wqueue/kwork_thread.c @@ -211,8 +211,7 @@ static int work_thread(int argc, FAR char *argv[]) * so ourselves, and (2) there will be no changes to the work queue */ - flags = spin_lock_irqsave(&wqueue->lock); - sched_lock(); + flags = spin_lock_irqsave_nopreempt(&wqueue->lock); /* If the wqueue timer is expired and non-active, it indicates that * there might be expired work in the pending queue. @@ -247,16 +246,14 @@ static int work_thread(int argc, FAR char *argv[]) kworker->work = work; - spin_unlock_irqrestore(&wqueue->lock, flags); - sched_unlock(); + spin_unlock_irqrestore_nopreempt(&wqueue->lock, flags); /* Do the work. Re-enable interrupts while the work is being * performed... we don't have any idea how long this will take! */ CALL_WORKER(worker, arg); - flags = spin_lock_irqsave(&wqueue->lock); - sched_lock(); + flags = spin_lock_irqsave_nopreempt(&wqueue->lock); /* Mark the thread un-busy */ @@ -271,8 +268,7 @@ static int work_thread(int argc, FAR char *argv[]) } } - spin_unlock_irqrestore(&wqueue->lock, flags); - sched_unlock(); + spin_unlock_irqrestore_nopreempt(&wqueue->lock, flags); /* Wait for the semaphore to be posted by the wqueue timer. */
