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/TM4C1294KCPDT: Sharing a mailbox between multiple tasks

Part Number: TM4C1294KCPDT


Tool/software: TI-RTOS

Hello,

We have a mailbox shared between multiple tasks. What care we should take?

Also is it allowed to share mailbox between task and ISR. If yes, what care we should take?

Thanks & Regards

Abhijit

  • Hi Charles,

    Thanks for your reply.

    How about shared mailbox between ISR and Task?

    Also will there be a possibility of low priority task can inhibit high priority task from running during Pend/Post operation? If yes, how to handle these situations?

    Thanks & Regards

    Abhijit

  • Hi,

      I'm not a TI-RTOS expert. I will ask our TI-RTOS experts to provide more guidance. From a mailbox standpoint, I don't think it matters if you are posting/pending a message from a task or an ISR. However, I'm not sure why would you want to do that? If the ISR is the consumer of the message and if the mailbox is empty, it will just pend waiting for a message to be place into the maibox. I don't think staying in the ISR for too long is a good thing. 

      In the Semaphore type configuration you can try the counting (priority-based). If two threads are sharing a priority-based semaphore, the higher priority thread will go to the head of the priority quie when it pends - thus getting the semaphore first when it is produced by the Hwi. 

      

      

  • Hi Abhijit,

    Abhijit Acharekar said:
    How about shared mailbox between ISR and Task?

    This is supported by SYS/BIOS.  The only limitation is that the ISR must use "polling" mode by using a timeout parameter of BIOS_NO_WAIT for both Mailbox_post() and Mailbox_pend(), since an ISR can't block.  When using BIOS_NO_WAIT, the Mailbox operation will return without blocking with the return value of TRUE or FALSE indicating whether or not a message was received (for Mailbox_pend()) or successfully posted (with Mailbox_post()).

    Abhijit Acharekar said:
    Also will there be a possibility of low priority task can inhibit high priority task from running during Pend/Post operation? If yes, how to handle these situations?

    Yes, "priority inversion" is possible with Mailboxes.  Mailboxes are a first-come, first-served resource, no matter the priority of the Tasks.  If a low priority Task blocks waiting for the Mailbox resource and a high priority Task then does the same, the low priority Task will be readied when the Mailbox resource becomes available and the high priority Task will continue to wait for the next available resource.  Internally, Mailboxes use Semaphores to control access, but SYS/BIOS does not offer the priority-based use of Semaphores within Mailboxes, that Charles pointed out.

    I'm not sure the above really qualifies as "priority inversion", it's more of a race condition as to who gets in line first.  There's really not much to be done to prevent this situation, and it is worth avoiding it.  It begs the question "why would you have 2 different priority Tasks receiving/sending from/to the same Mailbox?"

    Regards,

    - Rob

  • Hi Robert, Just for your information, Harshal is my colleague.

    Thanks,

    Abhijit

  • Abhijit,

    Making sure...it's okay to close this thread out...correct?

    Todd