mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 19:54:56 +00:00
freertos: Fix event group task list race condition
FreeRTOS synchronization primitives (e.g., queues, eventgroups) use various event lists (i.e., task lists) to track what tasks are blocked on a current primitive. Usually these event lists are accessed via one of the event lists functions (such as vTask[PlaceOn|RemoveFrom]UnorderedEventList()), which in turn ensure that the global task list spinlock (xTaskQueueMutex) is taken when accessing these lists. However, some functions in event_groups.c manually traverse their event lists. Thus if a tick interrupt occurs on another core during traversal and that tick interrupt unblocks a task on the event list being traversed, the event list will be corrupted. This commit modifies the following event_groups.c functions so that they take the global task list lock before traversing their event list. - xEventGroupSetBits() - vEventGroupDelete()
This commit is contained in:
@@ -3369,6 +3369,25 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
|
||||
TickType_t xTicksToWait,
|
||||
const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
||||
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
*
|
||||
* This function is a wrapper to take the "xTaskQueueMutex" spinlock of tasks.c.
|
||||
* This lock is taken whenver any of the task lists or event lists are
|
||||
* accessed/modified, such as when adding/removing tasks to/from the delayed
|
||||
* task list or various event lists.
|
||||
*
|
||||
* This functions is meant to be called by xEventGroupSetBits() and
|
||||
* vEventGroupDelete() as both those functions will access event lists (instead
|
||||
* of delegating the entire responsibility to one of vTask...EventList()
|
||||
* functions).
|
||||
*/
|
||||
void vTaskTakeEventListLock( void );
|
||||
void vTaskReleaseEventListLock( void );
|
||||
#endif // ESP_PLATFORM
|
||||
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
||||
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
|
Reference in New Issue
Block a user