adding task dynamically

iorek666 wrote on Thursday, September 02, 2010:

We want develop a product with FreeRtos that can add or remove task to system, in order to add or remove functionality.
For example our hardware have a  temperature sensor by an ADC  but there functionality is optional for some clients, then we want to remove the task that do this work and  add other task that sense other signals with i2c. But without change all the firmware and maybe the next month add again the temperature sensor  task without remove i2c task. I hope I was clear with my idea.  :smiley:

There is a way to have a “dynamic task manager” with FreeRTOS?. Any experience is welcome.

richard_damon wrote on Friday, September 03, 2010:

Free RTOS out of the box can add a task dynamically to the Kernel, the issue will be more an issue of how to add/remove the code from your overall program. This really isn’t a FreeRTOS type of issue, but a development tool issue. If you will have all the code in the machine at once, but only some tasks are activated at any given time this is easy, if you need to be able to change which modules are actually in memory, than your tool will need some form of dynamic or incremental linking ability.

iorek666 wrote on Thursday, September 09, 2010:

Well really we do not want to have a big code with many tasks, some of them active and others inactive. We want a kernel code with few tasks. This code has ONE firmware version and this firmware will not change. This firmware has to load other optional tasks like modules from a memory or filesystem??? We are not sure which is the best option.

This optionals tasks could change from one board to another and we want to remove or add them but without changing our kernel.

richard_damon wrote on Thursday, September 09, 2010:

This then is a tools issue, not a FreeRTOS issue, you need to make sure your tools support this form of dynamic linking of the add-on modules and your hardware needs to have some way to acquire and store these modules.

Note that the dynamic linking will also most likely need to be relocatable too, or you are going to have to divide you memory into sections, and each section can only load from a distinct set of modules (though some modules could be built for multiple sections if needed).

If your tools do not support dynamic linking (and that is sort of a rare feature in a lot of the embedded world), you are going to need to look at other options.

If the tools do support the needed dynamic linking, then adding in the FreeRTOS part of having the new module register tasks (and maybe queue, semaphores, and mutexes) isn’t that hard to do.

It sounds like you haven’t completed the design work to be able to do the linking yet (which isn’t a kernel function, but a tool issue),