Queue of pointers objects

The queue of pointers allows to exchange the data between tasks. It is a FIFO (First In, First Out) based queue implementation. The data are put in the end of queue and read from its beginning. The queue of pointers allows storing a defined number of messages of PVOID type. The maximal number of messages is restricted and determined during queue creation.

Queue of pointers creation and deletion

The function osCreatePtrQueue creates a queue of pointers object. The queue of pointers can be created before system start, from an interrupt handler or by a task. During queue of pointers creation, an optional object name may be specified. It makes tasks able to open it by osOpenPtrQueue function. During queue of pointers creation and opening, its handle is returned. The handle is assigned by the system and it is used to discern the system objects. All operations performed on the queue of pointers except to specify its handle. The non-used queue of pointers should be closed with the osCloseHandle. Queue of pointers object will be deleted when it will be closed by all tasks that opened it. More information you can find in the system objects management section.

When queue of pointers objects are not used, the OS_USE_PTR_QUEUE constant may be set to 0, to reduce the output code.

Using a queue of pointers object

When it is created a queue of pointers, a memory buffer for the specified maximal number of messages stored in the queue is allocated. The maximal size of the message is constant and cannot exceed size of the PVOID size. The queue is in the non-signaled state if there are no messages.

To put the message in a queue, the osPtrQueuePost function should be called. An osPtrQueuePend function allows to read and next to remove the first message from the queue. To write the message without removing it, the osPtrQueuePeek function should be used. This function is available only when OS_PTR_QUEUE_PEEK_FUNC is set for 1.

Access to queue is synchronized by disabling the interrupts for a short time.

SpaceShadow documentation