I am looking at V9 with the aim of creating task pools for re-use in RAM limited real time systems. The idea is to statically create empty tasks at boot time then have a master task populate them depending on the device operating mode. No malloc-free memory heap is allowed.
My nitial thought is to provide a standard pool interface such as task_pool_request_task method and have it allocate a TCB and stack along with a task_pool_return_task method to hand back the resources once it is no longer required.
There seem to be a number of issues - questions.
a) the request method creates (statically) a task but note that the task handle is NOT unique to the executable code function as it is essentially a pointer to the TCB, which is shared among a number of potential code functions…
b) The TCB contains the link list elements for the task management so the kernel must guarantee that all these items have been removed from the kernel control lists before the TCB resource can be re-used. This is achieved by the task delete function. I am not sure that this can be checked externally in the application. If a task offers itself for deletion it is not deleted immediately but placed on the pending queue to be deleted next time the idle task is run.
So the question is are there any other issues ??? The pseudo code is below …
get_free_task_TCB_and_STACK // get one of the RAM blocks allocated at boot time
create_task // standard FreeRTOS static task creation
suspend_task // task will be started by high level mode control task
delete_task // standard FreeRTOS task deletion
return_free_task_TCB_and_STACK // hand back RAM block
Any comment or hints would be appreciated.
FYI … I am developing on Atmel Studio7 for SAM4N uP