Setting priority to Messages in a Messagecue

michel_thr wrote on Sunday, April 30, 2006:

Hey all,

Have a simple question, we’re using FreeRTOS in a school project in wich we’re programming a robot with one master and different slaves like the main control and the sensor and actuator controls. I’m designing the main control of the robot and looking for a way to implement a critial stop through a “panic button”. I want to do it with a messageque to the task wich is responseble for sending the messages to the slaves. But because it’s a critical event and anther event could have the communication resource I want to send a messege through a messagecue with a “high” priority to the “critical stop” message.
Is it possible in RTOS to set a certain (higher) priority to a single message within a messageque? I can’t seems to find such call in the information section of the page.
Could anyone answer this question and tell me what i have to call. Or present me an altered code of FreeRTOS wich can do this, if you have such code?

Tnx a lot for your time in advance.

Greetingz Michel

nobody wrote on Monday, May 01, 2006:

Hello Michel,

Sounds like you have a fun project going.

Could you assign a semaphore to ‘lock’ the comm. channel - and make your critical panic button stop task the highest priority task in the system?
As soon as the comm. channel is released - then the critical task could grab the semaphore (or token) and then send out the message to your slave processes.  If I’m understanding you correctly - you have a shared comm. channel between the master and slave tasks - assigning a semaphore to who has the comm. channel is a common way to solve the shared resource problem - but there are other ways.

Since this sounds like an ‘emergency shut-down’ of the system - you want to assign a task with the highest priority to this - and then grab the comm. channel as soon as you can to get your message out.

Make sure you don’t code yourself into a corner so  to speak locking the resource for too long - i.e. - lower priority task has token - waiting for a slow event to occur…you want to make sure that all tasks are cooperative with the shared comm. channel.

I think no matter how you approach this - your up against the same problem.  You have n tasks than need to share x resources - you could probably code up a message queuing scheme to prioritize messages - but your still solving the same problem.  I think using a semaphore to lock the comm. channel coupled with a high priority task with FreeRTOS is the way to go - but there are other approaches.  At least, the approach I’ve outlined is what I would try first.

Good luck with your project and hope this helps!
John W.