mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
freertos: Fix configASSERT thread safety
This commit fixes thread safety issues with configASSERT() calls regarding the value of uxSchedulerSuspended. A false negative occurs if a context switch to the opposite core occurs in between the getting the core ID and the assesment. Closes https://github.com/espressif/esp-idf/issues/4230
This commit is contained in:
@ -1302,7 +1302,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
|
|||||||
//No mux; no harm done if this misfires. The deleted task won't get scheduled anyway.
|
//No mux; no harm done if this misfires. The deleted task won't get scheduled anyway.
|
||||||
if( pxTCB == pxCurrentTCB[ core ] ) //If task was currently running on this core
|
if( pxTCB == pxCurrentTCB[ core ] ) //If task was currently running on this core
|
||||||
{
|
{
|
||||||
configASSERT( uxSchedulerSuspended[ core ] == 0 );
|
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING )
|
||||||
|
|
||||||
/* The pre-delete hook is primarily for the Windows simulator,
|
/* The pre-delete hook is primarily for the Windows simulator,
|
||||||
in which Windows specific clean up operations are performed,
|
in which Windows specific clean up operations are performed,
|
||||||
@ -1337,7 +1337,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
|
|||||||
|
|
||||||
configASSERT( pxPreviousWakeTime );
|
configASSERT( pxPreviousWakeTime );
|
||||||
configASSERT( ( xTimeIncrement > 0U ) );
|
configASSERT( ( xTimeIncrement > 0U ) );
|
||||||
configASSERT( uxSchedulerSuspended[ xPortGetCoreID() ] == 0 );
|
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING );
|
||||||
|
|
||||||
taskENTER_CRITICAL(&xTaskQueueMutex);
|
taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||||
// vTaskSuspendAll();
|
// vTaskSuspendAll();
|
||||||
@ -1435,7 +1435,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
|
|||||||
/* A delay time of zero just forces a reschedule. */
|
/* A delay time of zero just forces a reschedule. */
|
||||||
if( xTicksToDelay > ( TickType_t ) 0U )
|
if( xTicksToDelay > ( TickType_t ) 0U )
|
||||||
{
|
{
|
||||||
configASSERT( uxSchedulerSuspended[ xPortGetCoreID() ] == 0 );
|
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING );
|
||||||
taskENTER_CRITICAL(&xTaskQueueMutex);
|
taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||||
// vTaskSuspendAll();
|
// vTaskSuspendAll();
|
||||||
{
|
{
|
||||||
@ -1818,7 +1818,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
|
|||||||
if( xSchedulerRunning != pdFALSE )
|
if( xSchedulerRunning != pdFALSE )
|
||||||
{
|
{
|
||||||
/* The current task has just been suspended. */
|
/* The current task has just been suspended. */
|
||||||
configASSERT( uxSchedulerSuspended[ xPortGetCoreID() ] == 0 );
|
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING );
|
||||||
portYIELD_WITHIN_API();
|
portYIELD_WITHIN_API();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2214,7 +2214,7 @@ BaseType_t xAlreadyYielded = pdFALSE;
|
|||||||
|
|
||||||
/* If uxSchedulerSuspended[ xPortGetCoreID() ] is zero then this function does not match a
|
/* If uxSchedulerSuspended[ xPortGetCoreID() ] is zero then this function does not match a
|
||||||
previous call to vTaskSuspendAll(). */
|
previous call to vTaskSuspendAll(). */
|
||||||
configASSERT( uxSchedulerSuspended[ xPortGetCoreID() ] );
|
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED );
|
||||||
/* It is possible that an ISR caused a task to be removed from an event
|
/* It is possible that an ISR caused a task to be removed from an event
|
||||||
list while the scheduler was suspended. If this was the case then the
|
list while the scheduler was suspended. If this was the case then the
|
||||||
removed task will have been added to the xPendingReadyList. Once the
|
removed task will have been added to the xPendingReadyList. Once the
|
||||||
|
Reference in New Issue
Block a user