Re: Message Queues

Olga Syrbachova <syrba4eva28@...>

Thank you very much for your reply! Unfortunately I can't find samples/scheduler/metairq_dispatch neither on the website of zephyrproject nor on  GIT. Could you please tell me where I can find  msgdev.c?

And also I would like to know if it's the right way to build my own application by modifying a "synchronization" sample? I'm doing it right under $HOME/zephyrproject/zephyr/samples/synchronization/src. Or should I create a new file in another directory?

Many thanks in advance!

On Thu, 25 Mar 2021 at 07:52, Kim Boendergaard <kim.boendergaard@...> wrote:

Consider having a look at msgdev.c in samples/scheduler/metairq_dispatch


I think that clearly answer your questions


Best regards,

Kim Bøndergaard | Software Tech Lead, Esco Medical
Phone: +45 51 54 39 61


From: users@... <users@...> On Behalf Of Olga Syrbachova
Sent: Wednesday, 24 March 2021 15.29
To: users@...
Subject: [Zephyr-users] Message Queues


EXTERNAL — Use caution when opening link(s) or attachment(s)

Hi! I'm trying to create my own app. I decided to start by modifying a "synchronization" sample. In my app I want to have 2 threads and 1 queue, so one thread can send messages to this queue and another thread is reading messages from the queue. I didn't find any sample with queues and I'm not sure how exactly to make queues. And I don't understand what I should put in "data" here:


void producer_thread(void)
    struct data_item_type data;
    while (1) {
        /* create data item to send (e.g. measurement, timestamp, ...) */
        data = ...
        /* send data to consumers */
        while (k_msgq_put(&my_msgq, &data, K_NO_WAIT) != 0) {
            /* message queue is full: purge old data & try again */
        /* data item was successfully added to message queue */

Data is of type struct data_item_type and it has 3 items in the example on the website. Does it mean I have to initialize my data in this way for example:

data.field1 = 2; /* int = 2 */

data.field2 = 3; /* int = 3 */


I followed the tutorial on the website, but not all steps are clear to me. You can find my code on github:


Can you please suggest any sample with queues or tell me what I am doing wrong? Many thanks in advance.

[The information contained in this email (including any attachments) is confidential and is intended solely for the use of the named addressee. Any unauthorized use, disclosure, reproduction, copying, distribution, or other form of unauthorized dissemination of the contents is expressly prohibited. If you have received this communication in error, please notify the sender immediately by email and delete the original message. Opinions, conclusions and other information in this message represent the opinion of the sender and do not necessarily represent or reflect the views and opinions of Esco Group companies.]

Join to automatically receive all group messages.