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.

Queues

Other Parts Discussed in Thread: TMS320F28377D, SYSBIOS

Hi

I was going through RTOS workshop manual and kind of understood the application of Queues on TI-RTOS for 28x (TMS320F28377D) processor.

Its stated that Queues are used for single producer/single Consumer model which is very clear and straight forward.

I am wondering if this concept can be extended to a multiple producer/single consumer kind of model?

In my application, I have a state machine which gets inputs from several other threads. I am planning to use Queues to get these input messages from threads operating at different priority levels. Can some one throw some light on this?

I also kind of understood (but i could be wrong) that when this data exchange happens via Queues, the global interrupts are disabled briefly. Is this true? 

Thanks

Ram

  • You can use Queues in a multiple-writer/single-reader model, as long as you use the atomic versions of the API.

    Queue_get()/Queue_put() are the atomic versions, and they do disable interrupts briefly to achieve the atomicity.  Queue_dequeue()/Queue_enqueue() are the non-atomic versions, and will be slightly quicker than Queue_get()/Queue_put() APIs if you don't need the atomic behavior.

    There is also the Mailbox module, which has similar functionality to Queue, with the difference being that Mailbox has its own associated data storage whereas Queue needs to be embedded within user-allocated storage.

    Regards,

    - Rob

  • Hi Rob,

    Thanks a lot for your prompt response and the explanation.

    So if I consider using mail_box, does it also has a brief turning off of the interrupts while doing data exchange?

  • rambabu surada said:
    So if I consider using mail_box, does it also has a brief turning off of the interrupts while doing data exchange?

    Yes, both Mailbox_post() and Mailbox_pend() have brief periods in which interrupts are globally disabled.  You can see the source code yourself in <BIOS_INSTALL_DIR>/packages/ti/sysbios/knl, where you will find the source files Mailbox.c and Queue.c.  Look for code bracketed by Hwi_disable() ... Hwi_restore().

    These "critical sections" in Mailbox and Queue modules are quite short.  You are probably more interested in the SYS/BIOS benchmark for "Interrupt Latency", which represents the longest duration during which interrupts are disabled.  For more information on the interrupt latency and other SYS/BIOS benchmarks, please refer to the SYS/BIOS User's Guide Appendix B (current version is spruex3p).

    Regards,

    - Rob

  • Hi Rob,

    Thanks again for the awesome explanation.

    I have one more question.

    I am using Queues for message handling. I am wondering if there is any limit on the number of messages that can be put in the que

    This is from the TI work shop material. In the container, is there any limit on the number of messages that can be put in? like can we have 

    msg_1,msg_2...............msg_n?

  • Ram,

    There is no limit on the number of elements that can be placed in a Queue, since the memory used for the Queues is provided by the user.

    Regards,

    - Rob