This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

To Check Queue is filled

Part Number: TM4C123GH6PM

Tool/software: TI-RTOS

Hello ,

This might be a basic question. But I have been working on the same for past 2 days.

There are 2 tasks.  I am using a Queue for inter task Communication.

Before Queue_get( ) , I am checking the Queue_empty( )  to avoid reading unnecessary data.

Before Queue_put( ) , how to check if Queue is full /not , to avoid overflow of data ?

Regards,

Chandan

  • Hi Chandan,

    Technically, queues can not be full. What I mean is that the queue is a double-linked list (with prev and next pointers). The use must allocate the memory required by the elements and the queue functions simply assign the pointers. In theory, that means that you can create as many queue elements as you have memory available.

    So if you wanted to know how many elements you have in your queue, you would simply have to loop through the queue (by using queue_next) until you reach the head again.

    To find more information about queues, you can read the TI-RTOS Kernel User Guide and the APIs documentation. You will find both in the TI-RTOS installation directory. On my computer, the path to the documentation can be found here (the tirtos version might be different on your computer):

    C:/ti/tirtos_tivac_2_16_01_14/docs/

    There should be a documentation overview html page, in which the user guide and APIs can be found under the Kernel Documentation.

    As a side note, if you want to communicate between tasks, you could also look at mailboxes. They copy the data into the mailbox (so you don't need to dynamically assign memory) and you can block on the Mailbox until a new message arrives (Mailbox_pend). If the mailbox is full, the Mailbox_post function return false, and if it is empty, it will block until a message is added. If you do not want to block, you can specify a timeout.

    You can find information about mailboxes in the same documentation that I mentioned above.

    Regards,

    Michel