Skip to content

Commit

Permalink
kernel: k_msgq_put should trigger reschedule
Browse files Browse the repository at this point in the history
Make `k_msgq_put` as scheduler point to resolve
high priority thread can not preempt low priority
thread.

Signed-off-by: TaiJu Wu <[email protected]>
  • Loading branch information
TaiJuWu authored and kartben committed Dec 14, 2024
1 parent 42511c8 commit fc47180
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/kernel/services/data_passing/message_queues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ The following code builds on the example above, and uses the message queue
to pass data items from a producing thread to one or more consuming threads.
If the message queue fills up because the consumers can't keep up, the
producing thread throws away all existing data so the newer data can be saved.
Note that this api will trigger reschedule.

.. code-block:: c
Expand Down
2 changes: 1 addition & 1 deletion kernel/msg_q.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int z_impl_k_msgq_put(struct k_msgq *msgq, const void *data, k_timeout_t timeout

SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put, msgq, timeout, result);

k_spin_unlock(&msgq->lock, key);
z_reschedule(&msgq->lock, key);

return result;
}
Expand Down

0 comments on commit fc47180

Please sign in to comment.