The pointer queue facilitates data exchange between tasks via a FIFO (First-In, First-Out) implementation. Messages are appended to the end of the queue and retrieved from the head. The pointer queue stores a fixed number of PVOID messages. The maximum capacity is restricted and must be determined at the time of queue creation.
The osCreatePtrQueue function initializes a pointer queue object. Pointer queues can be created during system initialization, within an interrupt handler, or by a task. During creation, an optional object name may be specified, allowing tasks to access the queue using the osOpenPtrQueue function. Both creation and opening functions return a system-assigned handle, which is used to uniquely identify the object. All subsequent operations on the pointer queue require this handle. Unused pointer queues should be released using osCloseHandle. A pointer queue object is deleted only after it has been closed by all tasks that opened it. Further details can be found in the System Objects Management section.
If pointer queue objects are not required, the OS_USE_PTR_QUEUE constant may be set to 0 to reduce the total code footprint.
When a pointer queue is created, a memory buffer is allocated for the specified maximum number of messages. Each message is constant in size and matches the PVOID type. The queue remains in a non-signaled state as long as it contains no messages.
To post a message to the queue, call the osPtrQueuePost function. The osPtrQueuePend function allows a task to read and subsequently remove the first message from the queue. To read a message without removing it, use the osPtrQueuePeek function. This function is available only when OS_PTR_QUEUE_PEEK_FUNC is set to 1.
Access to the queue is synchronized by briefly disabling interrupts.