diff --git a/sched/clock/clock_adjtime.c b/sched/clock/clock_adjtime.c index a87e0f1e92..0effc2e241 100644 --- a/sched/clock/clock_adjtime.c +++ b/sched/clock/clock_adjtime.c @@ -116,6 +116,7 @@ static int adjtime_start(long long adjust_usec) } flags = spin_lock_irqsave(&g_adjtime_lock); + sched_lock(); /* Set new adjustment */ @@ -142,6 +143,7 @@ static int adjtime_start(long long adjust_usec) } spin_unlock_irqrestore(&g_adjtime_lock, flags); + sched_unlock(); return ret; } diff --git a/sched/misc/assert.c b/sched/misc/assert.c index 516d94ea10..969fbf68fe 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -840,6 +840,7 @@ void _assert(FAR const char *filename, int linenum, if (os_ready) { flags = spin_lock_irqsave(&g_assert_lock); + sched_lock(); } #if CONFIG_BOARD_RESET_ON_ASSERT < 2 @@ -913,5 +914,6 @@ void _assert(FAR const char *filename, int linenum, if (os_ready) { spin_unlock_irqrestore(&g_assert_lock, flags); + sched_unlock(); } } diff --git a/sched/wqueue/kwork_notifier.c b/sched/wqueue/kwork_notifier.c index 6b274e44f2..813b46c0a5 100644 --- a/sched/wqueue/kwork_notifier.c +++ b/sched/wqueue/kwork_notifier.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -360,6 +361,7 @@ void work_notifier_signal(enum work_evtype_e evtype, */ flags = spin_lock_irqsave(&g_notifier_lock); + sched_lock(); /* Process the notification at the head of the pending list until the * pending list is empty @@ -403,6 +405,7 @@ void work_notifier_signal(enum work_evtype_e evtype, } spin_unlock_irqrestore(&g_notifier_lock, flags); + sched_unlock(); } #endif /* CONFIG_WQUEUE_NOTIFIER */ diff --git a/sched/wqueue/kwork_queue.c b/sched/wqueue/kwork_queue.c index 63741b3f5d..1ced5c797e 100644 --- a/sched/wqueue/kwork_queue.c +++ b/sched/wqueue/kwork_queue.c @@ -69,6 +69,7 @@ static void work_timer_expiry(wdparm_t arg) FAR struct work_s *work = (FAR struct work_s *)arg; irqstate_t flags = spin_lock_irqsave(&work->wq->lock); + sched_lock(); /* We have being canceled */ @@ -78,6 +79,7 @@ static void work_timer_expiry(wdparm_t arg) } spin_unlock_irqrestore(&work->wq->lock, flags); + sched_unlock(); } static bool work_is_canceling(FAR struct kworker_s *kworkers, int nthreads, @@ -182,8 +184,10 @@ int work_queue_wq(FAR struct kwork_wqueue_s *wqueue, if (!delay) { + sched_lock(); queue_work(wqueue, work); spin_unlock_irqrestore(&wqueue->lock, flags); + sched_unlock(); } else { diff --git a/sched/wqueue/kwork_thread.c b/sched/wqueue/kwork_thread.c index 84a51770cb..74e3b8b294 100644 --- a/sched/wqueue/kwork_thread.c +++ b/sched/wqueue/kwork_thread.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -204,7 +205,9 @@ static int work_thread(int argc, FAR char *argv[]) while (kworker->wait_count > 0) { kworker->wait_count--; + sched_lock(); nxsem_post(&kworker->wait); + sched_unlock(); } }