Skip to content

Commit c42cde5

Browse files
Flavio Ceolinnashif
authored andcommitted
kernel: work_q: Fix k_work_queue_start documentation
Inform that the queue has to be initialized in zeroed memory or with the k_work_queue_init before use. Signed-off-by: Flavio Ceolin <[email protected]>
1 parent d9aa414 commit c42cde5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

doc/reference/kernel/threads/workqueue.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ Defining and Controlling a Workqueue
222222
====================================
223223

224224
A workqueue is defined using a variable of type :c:struct:`k_work_q`.
225-
The workqueue is initialized by defining the stack area used by its thread
226-
and then calling :c:func:`k_work_queue_start`. The stack area must be defined
227-
using :c:macro:`K_THREAD_STACK_DEFINE` to ensure it is properly set up in
225+
The workqueue is initialized by defining the stack area used by its
226+
thread, initializing the :c:struct:`k_work_q`, either zeroing its
227+
memory or calling :c:func:`k_work_queue_init`, and then calling
228+
:c:func:`k_work_queue_start`. The stack area must be defined using
229+
:c:macro:`K_THREAD_STACK_DEFINE` to ensure it is properly set up in
228230
memory.
229231

230232
The following code defines and initializes a workqueue:
@@ -238,6 +240,8 @@ The following code defines and initializes a workqueue:
238240
239241
struct k_work_q my_work_q;
240242
243+
k_work_queue_init(&my_work_q);
244+
241245
k_work_queue_start(&my_work_q, my_stack_area,
242246
K_THREAD_STACK_SIZEOF(my_stack_area), MY_PRIORITY,
243247
NULL);

include/kernel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3061,7 +3061,9 @@ void k_work_queue_init(struct k_work_q *queue);
30613061
* This configures the work queue thread and starts it running. The function
30623062
* should not be re-invoked on a queue.
30633063
*
3064-
* @param queue pointer to the queue structure.
3064+
* @param queue pointer to the queue structure. It must be initialized
3065+
* in zeroed/bss memory or with @ref k_work_queue_init before
3066+
* use.
30653067
*
30663068
* @param stack pointer to the work thread stack area.
30673069
*

0 commit comments

Comments
 (0)