Problems with vTaskDelete(NULL)
Posted by the-moog
on April 12, 2007
I have two tasks that are mutually exclusive front ends for a piece of embedded software.
One of the tasks is initially created by another task.
When this new task receives a given command, it creates the other task and deletes itself.
When I do this the code seems to restart at the function being run at the time that the first task was deleted.
Task 1 creats task 2, then idles
Task 2 later receives a command which starts task 3, task 2 then kills itself with vTaskDelete(NULL).
Task 3 later receives a command which starts task 2, task 3 then kills itself with vTaskDelete(NULL). But it seems that task 2 then immediately suspends or yields to the now dead task 3.
The same function is called by task 1, 2 and 3 for creating and deleting tasks, 2 and 3 are created with the same priority.
I can't trace what exactly happens as it happens inside the RTOS kernel which the debugger (insight/gdb) has problems with tracing.
I thought perhaps task 2, when being re-created is resuming at the last function it was running when it was killed, which is the single task change function.
What other mechanisms can I use to trace the problem?
Using FreeRTOS v4.0.4 on an LPC/ARM7, is this a known problem? Will updating to a newer FreeRTOS solve it? (so far avoided this as it may cause a lot more work)
RE: Problems with vTaskDelete(NULL)
Posted by Richard
on April 12, 2007
Sounds very odd, and not a known problem. I don't think anything in later versions will change anything in this area.
A couple of things to check:
1) Is the idle task being starved out (not getting any processing time)? The idle task performs some clean up of tasks that have been deleted.
2) Are you checking the return value of xTaskCreate()? It might be that the function is failing because of memory allocation problems.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.