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.

RTOS/TM4C123GH6PM: Buffer size - Producer consumer Model

Part Number: TM4C123GH6PM

Tool/software: TI-RTOS

Hi Everyone,

I apologize in advance for asking comparatively irrelevant question but one thing I am 100% sure is that this is the exact forum where EXPERTS can guide you properly (Thanks TI). I am working on a TI-RTOS project that involve CAN communication. I have few TSKs; one (with higher priority) produces data by capturing CAN messages and putting them in appropriate Buffers (Queues) while the other tasks reads messages from Queue and process them. So there is a producer consumer model between the tasks. My question is:

  • Let's say the producer is producing data at X-bytes/sec and the other tasks can process them at Y-bytes/sec. So is there any relation that will give a clue what should be the appropriate size of buffer between the tasks?

In Simple words, how to estimate Queue size between two tasks implementing a Producer-Consumer model?

Kind Regards, 

  • Hi,
    My understanding of the the queue is that queue size is limited only by memory – it can be as big or as small as you like – you do not need to define this up front. If you don’t know exactly what the needs are in the system at boot time, Queues should be able to expand/contract based on runtime needs.

    Section 4.5 of the SYS/BIOS user's guide talks about the queue where various APIs are provided to interrogate the runtime usage of the queue. www.ti.com/.../spruex3u.pdf. If the consumer thread is for some reason dead and never receives the semaphore signal from the producer thread then the producer can find out the queue well being before overwhelming the queue. This is my take of the situation.
  • Thanks for your reply.

    So it means there is no mathematical calculation that can give us a clue of queue size??
  • I'm not an TI-RTOS expert but I think you can determine the queue size. The message will contain whatever the programmer decides to create – it is simply a structure defined by the programmer. It could hold pointers, buffers, variables, whatever you like. You can use the sizeof() to find out the size of your message and then decide how much buffer space for the queue depending on how many messages you can potentially have outstanding.