diff --git a/doc/reference/kernel/threads/workqueue.rst b/doc/reference/kernel/threads/workqueue.rst index 91f97759b74..8611ae5fb9e 100644 --- a/doc/reference/kernel/threads/workqueue.rst +++ b/doc/reference/kernel/threads/workqueue.rst @@ -222,9 +222,11 @@ Defining and Controlling a Workqueue ==================================== A workqueue is defined using a variable of type :c:struct:`k_work_q`. -The workqueue is initialized by defining the stack area used by its thread -and then calling :c:func:`k_work_queue_start`. The stack area must be defined -using :c:macro:`K_THREAD_STACK_DEFINE` to ensure it is properly set up in +The workqueue is initialized by defining the stack area used by its +thread, initializing the :c:struct:`k_work_q`, either zeroing its +memory or calling :c:func:`k_work_queue_init`, and then calling +:c:func:`k_work_queue_start`. The stack area must be defined using +:c:macro:`K_THREAD_STACK_DEFINE` to ensure it is properly set up in memory. The following code defines and initializes a workqueue: @@ -238,6 +240,8 @@ The following code defines and initializes a workqueue: struct k_work_q my_work_q; + k_work_queue_init(&my_work_q); + k_work_queue_start(&my_work_q, my_stack_area, K_THREAD_STACK_SIZEOF(my_stack_area), MY_PRIORITY, NULL); diff --git a/include/kernel.h b/include/kernel.h index ec037962ea1..7183feef103 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -3061,7 +3061,9 @@ void k_work_queue_init(struct k_work_q *queue); * This configures the work queue thread and starts it running. The function * should not be re-invoked on a queue. * - * @param queue pointer to the queue structure. + * @param queue pointer to the queue structure. It must be initialized + * in zeroed/bss memory or with @ref k_work_queue_init before + * use. * * @param stack pointer to the work thread stack area. *