esp-idf/components/freertos
Angus Gratton f7b859ac84 freertos: Fix race condition using vTaskDelete() cross-core causing resource leak
Causes test added in parent commit to pass.

This race happens if the deleted task is running on the other CPU,
and is already spinning in a critical section waiting for xTaskQueueMutex
because it's about to be blocked for a resource.

The "deleted" task would end up blocked, possibly indefinitely, and
never actually deleted or its resources cleaned up by the idle tasks.

Details:

vTaskDelete() adds the target task to the xTasksWaitingTermination list,
expecting it to be yielded off CPU and then cleaned up later. However as soon as
vTaskDelete() releases xTaskQueueMutex, the target task runs and moves itself to the
xDelayedTaskList1. Because interrupts are already disabled on that CPU,
the "yield" to the other CPU sent by the vTaskDelete() comes afterward so
doesn't help.
2021-04-13 03:40:10 +00:00
..
include/freertos
port
test freertos: Add unit test for deleting task which may be blocking 2021-04-13 03:40:10 +00:00
CMakeLists.txt
FreeRTOS-openocd.c
History.txt
Kconfig
component.mk
croutine.c
event_groups.c
freertos_v8_compat.c
license.txt
linker.lf
list.c
queue.c
sdkconfig.rename
stream_buffer.c
tasks.c
timers.c