deleting task on PIC32MX

e-christenson wrote on Sunday, August 09, 2015:

To begin with, OP Valentin has two significant mis-understandings here that are hard to see for the experienced, might be worth adding to the documentation somewhere or making checkable by lint or a compiler or adding comments to the prototypes in the header file:

A hook function is not a task function. It is a piece of a system “task”(whether or not it has a TCB) within freeRTOS – examples being the system idle task and the idle hook and the scheduler and the tick hook. As such, failure of such functions to return means an essential part of the freeRTOS system is rendered inoperable.

With or without lint, an upgraded prototype for a task would be
NORETURN( void userTaskd(…); )
and an appropriate prototype for a hook function would be
MUST_RETURN( void vXyzHook(void); )

That makes the point both clear to everyone, and automatically checkable.

A second possible misconception is that the idle task is actually completely idle. It actually does something important – reclaiming memory from deleted tasks.

The third misconception is that taskYIELD is appropriate within the idle task. What lower-priority task would run when the idle task yields? Hint: the idle task itself, exactly where it left off. I don’t think that is what the OP had in mind…so I’ll speculate that OP has a higher priority something that he wants to run before the current scheduling tick is complete. That something should either be an interrupt or simply called once from the idle task hook.