Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Setting priority to Messages in a Messagecue

Posted by michel_thr on 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 FreeRTOS.org 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

RE: Setting priority to Messages in a Message

Posted by Nobody/Anonymous on May 1, 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.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner