• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/29-Dec-2025-6939

CMakeLists.txtD29-Dec-2025192 95

README.rstD29-Dec-20251.4 KiB5339

prj.confD29-Dec-202515 20

sample.yamlD29-Dec-2025285 1615

README.rst

1.. zephyr:code-sample:: msg_queue
2   :name: Message Queue
3
4   Implements a basic message queue producer/consumer thread pair.
5
6Overview
7********
8
9A sample demonstrating the basic usage of Zephyr message queues.
10A producer thread sends both normal and urgent messages to be retrieved
11by a consumer thread.
12
13Building and Running
14********************
15
16This application can be built and executed on QEMU as follows:
17
18.. zephyr-app-commands::
19   :zephyr-app: samples/kernel/msg_queue
20   :host-os: unix
21   :board: qemu_x86
22   :goals: run
23   :compact:
24
25To build for another board target, replace "qemu_x86" above with it.
26
27Sample Output
28=============
29
30Every normal message is put at the end of the queue, and they are delivered
31in FIFO order. Every "urgent" message is put at the beginning of the queue,
32and it is delivered first as long as no other "urgent" message comes in after
33it.
34
35In this sample, one producer thread sends 1 urgent message for each 2 normal
36ones. Note that message C is the first retrieved because it was the last one
37sent as "urgent".
38
39.. code-block:: console
40
41   [producer] sending: 0
42   [producer] sending: 1
43   [producer] sending: A (urgent)
44   [producer] sending: 2
45   [producer] sending: 3
46   [producer] sending: B (urgent)
47   [producer] sending: 4
48   [producer] sending: 5
49   [producer] sending: C (urgent)
50   [consumer] got sequence: CBA012345
51
52Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
53