freertos: Add multi-core OS startup race condition workaround

FreeRTOS uses a single "xSchedulerRunning" variable to tack whether the
scheduler has started, and this variable is set to "pdTRUE" by core 0
via calling vTaskStartScheduler().

However, with SMP FreeRTOS, there is a race condition where core 0 has
already started the scheduler and another core has not called xPortStartScheduler()
yet and calls some FreeRTOS API. Thus the resultant FreeRTOS API can
cause errors as it thinks the scheduler has started.

This commit adds a temporary workaround (by having each core maintain their
own "xSchedulerRunning" variable.
This commit is contained in:
Darian Leung
2022-06-25 17:03:09 +08:00
parent 3df4c01d62
commit 0cf1fd3a5a
3 changed files with 35 additions and 0 deletions

View File

@@ -3279,6 +3279,15 @@ void vTaskYieldWithinAPI( void );
#ifdef ESP_PLATFORM
#if ( configNUM_CORES > 1 )
/*
Workaround for non-thread safe multi-core OS startup (see IDF-4524)
This function must be called with interrupts disabled on all cores other than
core 0 during startup.
*/
void vTaskStartSchedulerOtherCores( void );
#endif // configNUM_CORES > 1
#include "idf_additions.h"
#endif //ESP_PLATFORM