This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTX - Mailbox

Issue:
My Task1 is sending message if(os_mbx_check() > 0)

Task 2 is waiting for message and reading the msg.(and assume it has low priority) like below:

Line 1: os_mbx_wait (client_task_mailbox, (void **)&ptrMessage, 0xFFFF);
{ Line 2: X = *(ptrMessage) ;
Line 3: _free_box (client_task_mpool, ptrMessage);
}

Assume I have 5 slots and Task1 has filled all the slots and now the mailbox is full, and task1 is waiting for at least 1 free slot.
Now Task 2 gets the chance to execute. As soon as Task 2 detects there is a message and when I am at line 2, say Task1 kicks in and now it detects one free slot and sends a message and I get Hard_Fault.

This is solved by declaring ONE EXTRA in _declare_box() as shown below:
os_mbx_declare (MsgBox,5);
_declare_box (mpool,sizeof(Flash_Data),6);

Any better solution?

Regards,
JD

Parents
  • Most often, the consumer are given the higher priority just so the producer doesn't get blocked with a full queue.

    When the producer have the higher priority, then it normally have some burst behaviour so that the queue length is based on the burst performance, while the producer will go to sleep after having emitted the burst.

    Anyway, your solution is probably the best if your producer does need to have higher prio and does fill the queue until full. The issue is - are the messages important enough that you can afford to have the producer stalling?

Reply
  • Most often, the consumer are given the higher priority just so the producer doesn't get blocked with a full queue.

    When the producer have the higher priority, then it normally have some burst behaviour so that the queue length is based on the burst performance, while the producer will go to sleep after having emitted the burst.

    Anyway, your solution is probably the best if your producer does need to have higher prio and does fill the queue until full. The issue is - are the messages important enough that you can afford to have the producer stalling?

Children