arm - Good method to pass messages between embedded RTOS tasks (but can handle message timeouts gracefully) -


I am working with an embedded RTO (CMX), but I think it applies to any embedded RTOS The problem I am trying to communicate between different tasks is that one task sometimes 'locks' every other task for a long time (several seconds).

Since I do not wait for ACK for messages after 100 MS or 100 MS, so if I send a mailbox message during this time, the message that the message sends to answer is now Not waiting, but the received work will get the message and will try to take action on it. The problem is that the received work has an indicator for the message, but since the sending job is on, the indicator is no longer indicating the message, which can cause major problems.

I have no way to delete messages after they are in queue How can I handle this error?

This question really covers many different issues / points.

First of all, I am thinking that why does not one work for the CPU at one time at a time, generally it is a sign of a design problem. But I do not know your system, and it may be that there is a proper explanation, then I will not go down the hole of that rabbit.

So from your statement, you are encrypting the messages, not copies of messages, nothing is wrong with this but the problem that you describe can be exactly the encounter.

There are at least 2 solutions to this problem without knowing more, I can not say which of these could be better.

The first approach must pass a copy of the message, instead of an indicator. For example, VxWorks msg queue (not explicitly the CMX queue) you have a copy of the message enc. I do not know whether CMX supports such a model, and I do not know if you have bandwidth / memory to support such an approach. Usually when I can do it to avoid this approach, but it sometimes has its place.

The second approach, which I can do in this situation, is to assign a message buffer to the sender (usually my own message / buffer pool, definitely a fixed list of fixed-size memory blocks - But this is an implementation description - see "memory pool" for an example of what I'm talking about). However - after the allocation, the sender fills in the message data, presses an indicator in the message, and releases the control (ownership) of the memory block (i.e., message) receiver now After reading the message, is responsible for releasing / redeeming memory .

There are other issues that can be raised in this question, for example if the sender transmits "msg" to more than one receiver? How do receivers coordinate / communicate so that only the last reader can release the memory (garbage collection)? But hopefully from what you ask, the second solution will work for you. The second solution will work for you.


Comments