Skip to content

Commit 17b7a82

Browse files
kernel: sched: assert sys_workq is not unreadied while busy
The system workqueue should never be unreadied from a work item handler (while busy). This assert will help avoid deadlocking the system work queue, which is an exceptionally hard bug to hunt down. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 9f40c5d commit 17b7a82

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

doc/kernel/services/threads/workqueue.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ its queue until the handler function finishes executing.
109109
potentially blocking, as there is no guarantee that work items submitted to
110110
it do not depend on subsequent work items in the queue to unblock them.
111111

112+
Attempting to perform a blocking call will fail an assert if
113+
:kconfig:option:`CONFIG_ASSERT` is enabled.
114+
112115
The single argument that is passed to a handler function can be ignored if it
113116
is not required. If the handler function requires additional information about
114117
the work it is to perform, the work item can be embedded in a larger data

kernel/sched.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ static inline void z_vrfy_k_thread_resume(k_tid_t thread)
523523

524524
static void unready_thread(struct k_thread *thread)
525525
{
526+
__ASSERT_NO_MSG(!k_is_in_sys_work());
526527
if (z_is_thread_queued(thread)) {
527528
dequeue_thread(thread);
528529
}

0 commit comments

Comments
 (0)