Interprocess communication (IPC) mechanisms provided by Sirius RTOS deliver high-performance data exchange between tasks. The kernel offers several specialized objects, including shared memory, queues, mailboxes, streams, and queues of pointers.
Shared memory is an object that allocates a memory buffer and synchronizes access to it. Access can be protected either by a mutex-which includes priority inversion avoidance-or by a higher-performance auto-reset event object. Further details regarding shared memory implementation can be found in the following sections and in the dedicated shared memory chapter.
Queues are system objects designed for FIFO (First In, First Out) data exchange between tasks. Once a task writes data to the queue, it becomes available for another task to read. The message size and the maximum capacity of the queue are fixed and must be determined at creation time. For details on synchronization methods and direct read-write features, please refer to the following sections and the Queues chapter.
Mailboxes function similarly to queues, facilitating FIFO-based data exchange. When data is posted to a mailbox, it can be retrieved by a reading task. The primary distinction is that mailbox message sizes and quantities are limited only by available system memory. Unless a direct read-write operation is utilized, the kernel allocates a memory block for each message when it is posted. This memory is automatically freed when the message is read, or if the mailbox is cleared or deleted. Mailboxes are recommended for general-purpose applications where message sizes may vary. More information is available below and in the mailboxes chapter.
Streams are utilized for reading and writing data of arbitrary lengths. Data is processed byte-by-byte in a FIFO manner within the stream buffer. Streams are ideal for streaming data applications, such as transferring raw audio from a microphone to a processing task. For further details on stream synchronization and direct read-write modes, see the following sections and the streams chapter.
The queue of pointers is a specialized object similar to a standard queue. The maximum number of entries is fixed at creation, and each message size is restricted to the size of a PVOID.
This provides an extremely high-speed queue implementation. Synchronization is achieved through short-term interrupt disabling. Attempting to post to a full queue or read from an empty queue will result in an immediate error. The queue of pointers is particularly well-suited for passing data from Interrupt Service Routines (ISRs) to tasks. Detailed specifications are available in the queue of pointers chapter.
Read and write operations may be performed using object-specific functions or via generic system calls such as osRead and osWrite. These system functions allow for the specification of additional parameters, such as operation timeouts. For more information, please refer to the function API descriptions.
IPC mechanisms utilize internal memory buffers. In a multitasking environment, access to these buffers must be synchronized to prevent data corruption or race conditions. Queues, mailboxes, and streams support three distinct synchronization methods:
The shared memory object supports only the first two methods. For small data exchanges within shared memory, manual synchronization can be performed using the arLock and arRestore functions.
When a task attempts to read from an empty buffer or write to a full buffer in queues, mailboxes, or streams, it can be configured to block until the operation can be completed. This blocking behavior is enabled by the OS_IPC_WAIT_IF_EMPTY and OS_IPC_WAIT_IF_FULL flags at creation. Note that these flags are ignored when the object is accessed from an ISR.
The OS_IPC_DIRECT_READ_WRITE flag can be used in conjunction with the wait flags. This mode ensures that if a task is already waiting for an IPC operation, data is transferred directly between tasks without being buffered, further optimizing performance.