anonymous wrote on Friday, May 20, 2011:
I’m working on a system using FreeRTOS as the base platform. In it, I create several tasks that perform various operations. Nothing new here. On top of this, I am trying to implement a Task Watchdog. Basically, the watchdog pings every task running in the system to make sure that it is running and responsive. In the case that a task becomes unresponsive, I want to reset that task and free any memory it has allocated for itself. In FreeRTOS, I can do most of this using vTaskDelete() and xTaskCreate() and wait for the idle task to free memory in the task’s stacl that is being reset. This works fine except for one thing. The memory that is freed is just the task stack which is managed by the RTOS (this is documented). This includes return addresses pushed to the stack by calls from the task and any local variables. All other memory allocated (namely from the heap via malloc() or new) is not freed by the RTOS. The problem is that in a multitasking environment, any task can allocate memory from the global heap provided by the compiler/linker. So, when I delete a task, I have to pick out all the individual memory blocks I allocated in the task in order to free it. Freeing the entire heap would wipe out memory for all tasks (something that would be catastrophic). Instead, I’d like to allocate a memory block (local heap) for a task when it is created. If I have to kill a task and free any memory that was allocated in that task, I simply free that task’s local heap. That feature is not provided in the official release of FreeRTOS.
Has anyone come across this problem? Do you have a solution or can you point me in the right direction?
Thanks for your help.