kernel: work_queue: make thread essential flag configurable

Allow the creator of a work_queue instance to choose whether
the work_queue thread should be marked as ESSENTIAL or not.

Signed-off-by: Mohamed ElShahawi <ExtremeGTX@hotmail.com>
This commit is contained in:
Mohamed ElShahawi 2024-03-17 21:40:49 +01:00 committed by Carles Cufí
parent 2765d23775
commit 9ba4653243
2 changed files with 9 additions and 0 deletions

View file

@ -4004,6 +4004,11 @@ struct k_work_queue_config {
* control. * control.
*/ */
bool no_yield; 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. */ /** @brief A structure used to hold work until it can be processed. */

View file

@ -761,6 +761,10 @@ void k_work_queue_start(struct k_work_q *queue,
k_thread_name_set(&queue->thread, cfg->name); 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); k_thread_start(&queue->thread);
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_queue, start, queue); SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_work_queue, start, queue);