nobody wrote on Saturday, April 01, 2006:
If a task calls vTaskDelete() passing its own task
handle rather than NULL, then there can be a problem.
This is because the final taskYIELD() is not called.
I fixed it by putting the following within the
critical section of the main body of vTaskDelete()
after it gets the pointer to the TCB to delete:
if ((tskTCB *)pxTaskToDelete==pxCurrentTCB)
pxTaskToDelete = NULL;
(Testing pxCurrentTCB must be protected.)
Although it may seem strange to call vTaskDelete() with
the running task’s handle, my situation was that it
was being called from some common task cleanup code that was
unaware if who was calling it. Of course, the fix could be at
the point of call, but my feeling is that it best belongs
in the vTaskDelete() function.
A point of interest - I found that the problem can
manifest itself as intermittent. If an interrupt reschedules
another task a just the right moment, then the taskYIELD()
is, of course, unnecessary. It made for interesting
debugging, because when I single stepped through vTaskDelete()
everything worked fine, but normally it it didn’t.
… I use the ARM7 port.