diff --git a/include/zephyr/kernel.h b/include/zephyr/kernel.h index da43eea977..6a3bd04c0a 100644 --- a/include/zephyr/kernel.h +++ b/include/zephyr/kernel.h @@ -4004,6 +4004,11 @@ struct k_work_queue_config { * control. */ bool no_yield; + + /** Control whether the work queue thread should be marked as + * essential thread. + */ + bool essential; }; /** @brief A structure used to hold work until it can be processed. */ diff --git a/kernel/work.c b/kernel/work.c index cf73bdbcab..1615c321f7 100644 --- a/kernel/work.c +++ b/kernel/work.c @@ -761,6 +761,10 @@ void k_work_queue_start(struct k_work_q *queue, k_thread_name_set(&queue->thread, cfg->name); } + if ((cfg != NULL) && (cfg->essential)) { + queue->thread.base.user_options |= K_ESSENTIAL; + } + k_thread_start(&queue->thread); SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_queue, start, queue);