mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'bugfix/scheduler_state_query_thread_safety_v4.4' into 'release/v4.4'
freertos: fix thread safety for checking scheduler state (v4.4) See merge request espressif/esp-idf!16126
This commit is contained in:
@ -1468,7 +1468,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB,
|
|||||||
|
|
||||||
configASSERT( pxPreviousWakeTime );
|
configASSERT( pxPreviousWakeTime );
|
||||||
configASSERT( ( xTimeIncrement > 0U ) );
|
configASSERT( ( xTimeIncrement > 0U ) );
|
||||||
configASSERT( uxSchedulerSuspended[xPortGetCoreID()] == 0 );
|
configASSERT( xTaskGetSchedulerState() != taskSCHEDULER_SUSPENDED );
|
||||||
|
|
||||||
#ifdef ESP_PLATFORM // IDF-3755
|
#ifdef ESP_PLATFORM // IDF-3755
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
@ -1563,7 +1563,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB,
|
|||||||
/* 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_SUSPENDED );
|
||||||
#ifdef ESP_PLATFORM // IDF-3755
|
#ifdef ESP_PLATFORM // IDF-3755
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
#else
|
#else
|
||||||
@ -2507,9 +2507,9 @@ BaseType_t xTaskResumeAll( void )
|
|||||||
BaseType_t xAlreadyYielded = pdFALSE;
|
BaseType_t xAlreadyYielded = pdFALSE;
|
||||||
TickType_t xTicksToNextUnblockTime;
|
TickType_t xTicksToNextUnblockTime;
|
||||||
|
|
||||||
/* If uxSchedulerSuspended[xPortGetCoreID()] is zero then this function does not match a
|
/* If scheduler state is `taskSCHEDULER_RUNNING` then this function does not match a
|
||||||
* previous call to taskENTER_CRITICAL(). */
|
* previous call to taskENTER_CRITICAL(). */
|
||||||
configASSERT( uxSchedulerSuspended[xPortGetCoreID()] );
|
configASSERT( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING );
|
||||||
|
|
||||||
/* 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
|
||||||
@ -2968,7 +2968,7 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp )
|
|||||||
|
|
||||||
/* Must not be called with the scheduler suspended as the implementation
|
/* Must not be called with the scheduler suspended as the implementation
|
||||||
* relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */
|
* relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */
|
||||||
configASSERT( uxSchedulerSuspended[xPortGetCoreID()] == 0 );
|
configASSERT( xTaskGetSchedulerState() != taskSCHEDULER_SUSPENDED );
|
||||||
|
|
||||||
/* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occuring when
|
/* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occuring when
|
||||||
* the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */
|
* the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */
|
||||||
@ -4665,7 +4665,9 @@ static void prvResetNextTaskUnblockTime( void )
|
|||||||
BaseType_t xTaskGetSchedulerState( void )
|
BaseType_t xTaskGetSchedulerState( void )
|
||||||
{
|
{
|
||||||
BaseType_t xReturn;
|
BaseType_t xReturn;
|
||||||
|
unsigned state;
|
||||||
|
|
||||||
|
state = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||||
if( xSchedulerRunning == pdFALSE )
|
if( xSchedulerRunning == pdFALSE )
|
||||||
{
|
{
|
||||||
xReturn = taskSCHEDULER_NOT_STARTED;
|
xReturn = taskSCHEDULER_NOT_STARTED;
|
||||||
@ -4681,6 +4683,7 @@ static void prvResetNextTaskUnblockTime( void )
|
|||||||
xReturn = taskSCHEDULER_SUSPENDED;
|
xReturn = taskSCHEDULER_SUSPENDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
portCLEAR_INTERRUPT_MASK_FROM_ISR(state);
|
||||||
|
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user