Skip to content
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Home
  • Download Now!
  • GeMRTOS
    • License
    • Download
    • GeMRTOS Documentation
      • Documentation Browser
      • GeMRTOS Manuals
    • GeMRTOS repository
  • Log in
  • Contact us
Search
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Download Now!!!
  • GeMRTOS
    • License
    • Download now!
    • GeMRTOS documentation
    • GeMRTOS repository
  • Login
  • Contact us
  • FPGA Laboratory ACCESS
  • Cursos de FPGA (en español)
  • Challenges
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Home
  • Download Now!
  • GeMRTOS
    • License
    • Download
    • GeMRTOS Documentation
      • Documentation Browser
      • GeMRTOS Manuals
    • GeMRTOS repository
  • Log in
  • Contact us
Search
GeMRTOS
GeMRTOS

The Generic eMbedded Multiprocessor RTOS

  • Download Now!!!
  • GeMRTOS
    • License
    • Download now!
    • GeMRTOS documentation
    • GeMRTOS repository
  • Login
  • Contact us
  • FPGA Laboratory ACCESS
  • Cursos de FPGA (en español)
  • Challenges

GeMRTOS - Getting started

  • Introduction to GeMRTOS
  • Creating your first GeMRTOS application
  • API references
  • Platforn Designer flow
  • Tasks and periods in RTOSs
  • Installation of Quartus Prime with WSL ([1]) for GeMRTOS design flow.

GeMRTOS - Features

  • Synchronization, Critical Sections and Mutex in Multiprocessor RTOSs
  • Signals in GeMRTOS
  • GeMRTOS system architecture
  • Introduction to GeMRTOS: Hybrid partition scheduling.
  • Scheduling lists in GeMRTOS
  • Tasks in GeMRTOS
  • Trigger Resources in GeMRTOS
  • GeMRTOS Controller
  • Data structures and linked lists in GeMRTOS
  • Semaphores in GeMRTOS
  • Message Queue Resources in GeMRTOS

General

  • Error (16031): Current Internal Configuration mode does not support memory initialization or ROM. Select Internal Configuration mode with ERAM.
  • GeMRTOS partners with Intel
  • newlib reentrancy and thread-safe in multiprocessors
  • Specifying the License for the Questa*-Intel® FPGA Edition Software
  • Installing Nios II Software Built Tools (SBT) for Eclipse in Quartus Prime starting from version 19.1
  • Why do I get a fatal error when creating an ALTPLL IP?
  • SDRAM IP in DE2-115 board
  • Compiling beyond 256MB
  • Questa issues
  • Warning (113015): Width of data items in <mem_init>.hex is greater than the memory width
  • Processors with an ID other than 1 do not launch once the software has been downloaded.
  • System console does not start after Quartus Prime instalation
  • Eclipse does not start after full Quartus Prime instalation
  • Home
  • GeMRTOS KnowledgeBase
  • Message Queue Resources in GeMRTOS

Message Queue Resources in GeMRTOS

Message queues in GeMRTOS #

The message queue is a resource that enables independent tasks to exchange information. Information is sent using messages by a task (denoted producer ) to the message queue . A message remains associated with the message queue resources until (1) all the tasks associated with the message queue read it (aka consume it), or (2) a timeout expires. The producer task remain suspended until the message was consumed by all the consumers or the timeout of the message expires. The tasks that want to receive the messages sent to the message queue, have to subscribe to the message queue.

If a consumer task already received all the messages sent, then it remains suspended waiting until the next message.

Message queue related functions #

Creating and initializing a Message queue #

The first step is to create a message queue resource using:

G_RCB *gu_queue_create(void);

The gu_queue_create function creates a new message queue resource. The message queue resource is built using the G_RCB structure with some fields from the T_QUEUE_RESOURCE structure appended. A producer (associated with the waiting eevnt list) and a consumer (associated with the granted event list) event lists will be included in the newly constructed message queue resource. Producer tasks link a waiting event in the producer list of the message queue resource. The gu_queue_create can be called from either the main code or a task code. However, when it is executed within a task code, it must come before the execution of a send or a receive message function, or an error will be produced.

The message queue is created and initilized with the following paramenters:

The gu_queue_create function returns a pointer to the message queue resource created, or 0 if there is not more resources available. It should be used in all the functions related to the message queue resource created. The function returns a NULL pointer if there is not enough memory to implement the message queue resource.

Subscribing to a Message queue resource #

A consumer task should be subscribed to a message resource prior to receiving messages with the following function:

GS_ECB *gu_queue_subscribe(GS_TCB *ptcb, G_RCB *presource);

The gu_queue_subscribe function subscribes the current executing task to the message queue resource specified. A consumer tasks should be previously subscribe to the message queue resource in order to be able to receive messages with the gu_queue_receive function. The Message Queue should be created with gu_queue_create.

A message queue is subscribed with the following parameters:

NameDescription
ptcbIt is a pointer to the task's TCB to be subscribe to the queue
presourceIt is a pointer to the message queue resource to be subscribe to.
The gu_queue_subscribe function returns a pointer to the GS_ECB structure associated with the message queue resource.

Printing formatted messages to a Message queue resource #

A producer task sends formatted messages with the following function:

int gu_queue_printf(G_RCB *prcb, char *format,  ...);

The gu_queue_printf function serves to print a message to a message queue resource. This function operates in a manner where it will return once the message has been successfully delivered to all subscribed consumers or when a timeout occurs. During this period, the task invoking the gu_queue_printf function remains suspended. The primary purpose of this function is to transmit a formatted message to the designated queue resource, facilitating communication within a GeMRTOS-based system.

gu_queue_printf

A message is printed with the following parameters:

NameDescription
prcbIt is the pointer to the message queue resource. The pointer is the value returned by the gu_queue_create function when the message queue resource was created. It serves as a reference to the specific message queue where the formatted message will be sent using gu_queue_printf.
formatIt is the formatted message to be sent. The valid format of this message is similar to the original printf function, allowing it to contain embedded format tags. These format tags are replaced by the values specified in subsequent additional arguments and formatted as specified. This allows for flexible and customized message formatting within the gu_queue_printf function, akin to how the printf function operates.
G_TRUE when successful, G_FALSE otherwise

Sending messages to a Message queue resource #

A producer task sends messages with the following function:

int gu_queue_send(G_RCB *prcb, char *pmsg, int msg_length, gt_time timeout);

The gu_queue_send function sends a message to a message queue resource. The function returns when the message was delivered to all the consumer subscribed or the timeout, meanwhile the task remains suspended.

gu_queue_send

A message is sent with the following parameters:

NameDescription
prcbIt is the pointer to the message queue resource. The pointer is the value returned by the gu_queue_create function when the message queue resource was created.
pmsgIt is the pointer to the message to be sent.
msg_lengthIt is the lenght of the message to be sent.
timeoutIt is the timeout to send the message.
G_TRUE when successful, G_FALSE otherwise

Receiving messages from a Message queue resource #

A consumer task receives messages from a previously subscribed message queue resource with the following function:

int gu_queue_receive(G_RCB *prcb, void *buffer_msg, G_INT32 buffer_length);

The gu_queue_receive function receives the next message from the message queue resource. The task should be subscribed previously with the gu_queue_subscribe function. The new message is stored into the buffer pointed by the buffer_msg parameter. Up to buffer_length bytes are copied from the message sent. When the sent message is larger than the consumer buffer, then the message recieved is truncated in the buffer_length size.

A message is sent with the following parameters:

NameDescription
prcbIt is the pointer to the message queue resource already subscribed to.
buffer_msgIt is the pointer to the message buffer where the message received will be store into.
buffer_lengthThe maximum number of bytes to be received. It should be the length of the receiving buffer.
The gu_queue_receive function returns the number of bytes received.

Message queue resource related structure #

T_QUEUE_RESOURCE #

The T_QUEUE_RESOURCE is defined as the field "queue" in a G_RCB resource. So, the fields of the T_QUEUE_RESOURCE structure should be addressed as: (G_RCB *)->queue.<field>

Structure fields #

TypeFieldDescription
G_INT32 MQ_priority_send Priority for the next ECB to send (to put last)
G_INT32 MQ_msg_seq Number of sequence of the current message
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  • Message queues in GeMRTOS
  • Message queue related functions
    • Creating and initializing a Message queue
    • Subscribing to a Message queue resource
    • Printing formatted messages to a Message queue resource
    • Sending messages to a Message queue resource
    • Receiving messages from a Message queue resource
  • Message queue resource related structure
    • Structure fields

Copyright © 2025 - contact us - Dorrego 287 - B8000FLE - Bahía Blanca - Argentina - +542914311867  GeMRTOS

Nios II, Nios V, Quartus Prime, ModelsSim are property of their respective companies.
GeMRTOS is property of R. Cayssials.
**All contact forms on this site are protected by reCAPTCHA. Google Privacy

GeMRTOS joins Intel Partner Alliance as Gold member.