mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
fix(freertos/idf): Add missing critical sections to vTaskSuspendAll()
vTaskSuspendAll() requires critical sections when building for SMP. Otherwise, it is possible for a task to switch cores in between getting the core ID and before incremented uxSchedulerSuspended.
This commit is contained in:
@ -2462,11 +2462,15 @@ void vTaskEndScheduler( void )
|
||||
|
||||
void vTaskSuspendAll( void )
|
||||
{
|
||||
/* A critical section is not required as the variable is of type
|
||||
/* For SMP, we need to take the kernel lock here as we are about to access
|
||||
* kernel data structures.
|
||||
*
|
||||
* For single-core, a critical section is not required as the variable is of type
|
||||
* BaseType_t. Please read Richard Barry's reply in the following link to a
|
||||
* post in the FreeRTOS support forum before reporting this as a bug! -
|
||||
* https://goo.gl/wu4acr */
|
||||
|
||||
prvENTER_CRITICAL_SMP_ONLY( &xKernelLock );
|
||||
{
|
||||
/* portSOFTWARE_BARRIER() is only implemented for emulated/simulated ports that
|
||||
* do not otherwise exhibit real time behaviour. */
|
||||
portSOFTWARE_BARRIER();
|
||||
@ -2479,6 +2483,9 @@ void vTaskSuspendAll( void )
|
||||
* the above increment elsewhere. */
|
||||
portMEMORY_BARRIER();
|
||||
}
|
||||
/* Release the previously taken kernel lock. */
|
||||
prvEXIT_CRITICAL_SMP_ONLY( &xKernelLock );
|
||||
}
|
||||
/*----------------------------------------------------------*/
|
||||
|
||||
#if ( configUSE_TICKLESS_IDLE != 0 )
|
||||
|
Reference in New Issue
Block a user