mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Update for unpaired critical section in vTaskSuspend (#959)
* Move the taskEXIT_CRITICAL out of the configNUMBER_OF_CORES macro block to improve readability.
This commit is contained in:
parent
4d9f6522e5
commit
72c7d86276
31
tasks.c
31
tasks.c
|
@ -3107,10 +3107,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
{
|
{
|
||||||
TCB_t * pxTCB;
|
TCB_t * pxTCB;
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES > 1 )
|
|
||||||
BaseType_t xTaskRunningOnCore;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
traceENTER_vTaskSuspend( xTaskToSuspend );
|
traceENTER_vTaskSuspend( xTaskToSuspend );
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
|
@ -3121,10 +3117,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
|
|
||||||
traceTASK_SUSPEND( pxTCB );
|
traceTASK_SUSPEND( pxTCB );
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES > 1 )
|
|
||||||
xTaskRunningOnCore = pxTCB->xTaskRunState;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Remove task from the ready/delayed list and place in the
|
/* Remove task from the ready/delayed list and place in the
|
||||||
* suspended list. */
|
* suspended list. */
|
||||||
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
|
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
|
||||||
|
@ -3164,9 +3156,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
}
|
}
|
||||||
#endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
|
#endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
|
||||||
{
|
|
||||||
taskEXIT_CRITICAL();
|
taskEXIT_CRITICAL();
|
||||||
|
|
||||||
if( xSchedulerRunning != pdFALSE )
|
if( xSchedulerRunning != pdFALSE )
|
||||||
|
@ -3184,6 +3173,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
|
{
|
||||||
if( pxTCB == pxCurrentTCB )
|
if( pxTCB == pxCurrentTCB )
|
||||||
{
|
{
|
||||||
if( xSchedulerRunning != pdFALSE )
|
if( xSchedulerRunning != pdFALSE )
|
||||||
|
@ -3218,22 +3209,14 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
}
|
}
|
||||||
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
|
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
|
||||||
{
|
{
|
||||||
if( xSchedulerRunning != pdFALSE )
|
/* Enter critical section here to check run state of a task. */
|
||||||
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
/* Reset the next expected unblock time in case it referred to the
|
|
||||||
* task that is now in the Suspended state. */
|
|
||||||
prvResetNextTaskUnblockTime();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE )
|
if( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE )
|
||||||
{
|
{
|
||||||
if( xSchedulerRunning != pdFALSE )
|
if( xSchedulerRunning != pdFALSE )
|
||||||
{
|
{
|
||||||
if( xTaskRunningOnCore == ( BaseType_t ) portGET_CORE_ID() )
|
if( pxTCB->xTaskRunState == ( BaseType_t ) portGET_CORE_ID() )
|
||||||
{
|
{
|
||||||
/* The current task has just been suspended. */
|
/* The current task has just been suspended. */
|
||||||
configASSERT( uxSchedulerSuspended == 0 );
|
configASSERT( uxSchedulerSuspended == 0 );
|
||||||
|
@ -3241,7 +3224,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prvYieldCore( xTaskRunningOnCore );
|
prvYieldCore( pxTCB->xTaskRunState );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3258,7 +3241,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
{
|
{
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
taskEXIT_CRITICAL();
|
taskEXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
|
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
|
||||||
|
|
Loading…
Reference in a new issue