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

message bus IDEA in RTOS

I have an idea for RTX and other RTOS, adding message bus feature to them!

Like a CAN bus this bus operate but between tasks instead of devices.

Many times a task have a message that can publish and many tasks are user of that message, each message must have an 8bit identifier that will be published at head of message(no crc).

each task have an adjustable filter/mask that can receive messages that need to get.

This method is better than send on message to several tasks separately.

Parents
  • Remember that devices connected to a CAN bus are parallell devices - they all operate concurrently and each and everyone is resposible for being fast enough to handle received CAN messages.

    Threads in a RTOS environments are not concurrent. They run one-by-one and have different priorities. That means that they all must have their own receive queue to allow them to buffer received messages until they get access to the CPU to start consuming incomming data. This is why the "subscribe" model is so popular - any thread interested in a specific type of message subscribes to this data and registers a message queue or a callback function.

    The only other option besides having individual queues, would be for the message creator to donate the CPU time to do a round-robin pass through all interested threads to let them process the new message before the publisher thread finally gets back the CPU and can figure out when to generate a new message. But this does not work in a RTOS environment, because locking up the processor for a long time breaks the real-time requirements.

    So in the end, it's hard to do better than to send the new message to every interested consumer thread. Then each consumer is responsible for being able to consume received messages fast enough before the buffer space overflows.

Reply
  • Remember that devices connected to a CAN bus are parallell devices - they all operate concurrently and each and everyone is resposible for being fast enough to handle received CAN messages.

    Threads in a RTOS environments are not concurrent. They run one-by-one and have different priorities. That means that they all must have their own receive queue to allow them to buffer received messages until they get access to the CPU to start consuming incomming data. This is why the "subscribe" model is so popular - any thread interested in a specific type of message subscribes to this data and registers a message queue or a callback function.

    The only other option besides having individual queues, would be for the message creator to donate the CPU time to do a round-robin pass through all interested threads to let them process the new message before the publisher thread finally gets back the CPU and can figure out when to generate a new message. But this does not work in a RTOS environment, because locking up the processor for a long time breaks the real-time requirements.

    So in the end, it's hard to do better than to send the new message to every interested consumer thread. Then each consumer is responsible for being able to consume received messages fast enough before the buffer space overflows.

Children