Mode Change Library for FreeRTOS

Greetings!

My name is Giann. I am a PhD student working on real-time embedded systems, runtime monitors, and formal methods. One of the problems I want to tackle with my thesis is ensuring that whenever we deploy a set of monitors on a real-time system, these monitors will not turn the system unschedulable. To do that, I want to apply schedulability analysis algorithms to check the feasibility of adding a monitor (i.e., another task to be scheduled) to an existing schedulable task set.

With that said, I am particularly interested in the cases where real-time systems support mode changes (a.k.a. mode switching), where a system can transition between a pre-defined number of modes of execution. These modes need to be defined at design time and would consist of changes in the number of tasks and/or the scheduling parameters of the currently executing task set. For instance, task T1 could have a different period/priority in modes M1 and M2. In another example, M1 could have more/fewer tasks to schedule than M2. Regardless of what is modified in the task set, I’d like to check if the transition between modes is schedulable or not.

Although many papers in the literature deal with how to transition between modes, I can’t find a library or a practical implementation for FreeRTOS that enables mode changes. Does anyone know of any project/library that enables mode changes in FreeRTOS? Alternatively, could you provide a few pointers on what would need to be customized on FreeRTOS to achieve it? If there is any ongoing work in this direction, I’d be happy to contribute to it!

Thanks for taking the time to read it. I am looking forward to your reply!

FreeRTOS provides a very simple and generic scheduling model, and most of what you are talking about becomes very application specific, so it is not surprising that there isn’t direct support for this sort of thing.

Schedulability is a task left to the system programmer, so FreeRTOS itself never will hit an unschedulability problem (unless you break the rules and have the Idle task block, so FreeRTOS can’t find a ready task to schedule).

FreeRTOS’s scheduling is based on static priorities, and always running a highest priority ready task. More complicated scheduling algorithms either need to be reduced to this form of priorities, or needs the code to dynamically adjust the current priorities to affect the requirements.

This code would need to be invoked every time the requirements change, so as an example, if you want a nearest deadline first scheduling algorithm, you will need to keep track of the deadlines, and every time a change in deadlines occurs (like one is satisfied and that task now has a later deadline to meet) you enter a rescheduling function which adjusts the task priorities.

FreeRTOS’s only role in this is to provide the capability to change the priority of the tasks (which is does if you enable that cabability).

All of your “Schedualability” questions deal with things that FreeRTOS just doesn’t care about, and can’t know by itself, the set of dead-lines for the tasks and the resource requirements for the tasks. (And not all applications or scheduling models even need this sort of information). This is why that sort of operation is left to the application.

There may well be some sort of library somewhere that can take some from of description of this data and build a priority list. Such a library would be relatively OS independent, as FreeRTOS’s scheduling algorithm is fairly common for simple generic RTOSes.

1 Like

Hello, Richard!

First of all, thank you so much for taking the time to clarify how FreeRTOS works under the hood. I definitely needed something like this to expand my understanding of it.

I will leave the topic open in case someone happens to know works in the literature involving implementations of mode change-supported schedulers, even if they are not directly linked to FreeRTOS.

In the meanwhile, I’ll do some investigation on what it would take to implement it myself.

Once again, thank you!