Remove set current TCB

This commit is contained in:
Ching-Hsin,Lee 2024-07-08 11:16:26 +08:00
parent cb0b1ed882
commit 9362ac47c1

19
tasks.c
View file

@ -352,10 +352,6 @@
#if ( configNUMBER_OF_CORES == 1 ) #if ( configNUMBER_OF_CORES == 1 )
#define prvGetCurrentTaskTCB() pxCurrentTCB #define prvGetCurrentTaskTCB() pxCurrentTCB
#define prvGetCurrentTaskTCBUnsafe() pxCurrentTCB #define prvGetCurrentTaskTCBUnsafe() pxCurrentTCB
#define prvSetCurrentTaskTCBUnsafe( pxTCB ) \
do{ \
pxCurrentTCB = pxTCB; \
} while( 0 )
#else #else
/* Retrieving the current task TCB in a multi-core environment involves two steps: /* Retrieving the current task TCB in a multi-core environment involves two steps:
@ -365,10 +361,6 @@
* To ensure atomicity, prvGetCurrentTaskTCBUnsafe() should be called in a context where * To ensure atomicity, prvGetCurrentTaskTCBUnsafe() should be called in a context where
* the core executing the task remains fixed until the operation is completed. */ * the core executing the task remains fixed until the operation is completed. */
#define prvGetCurrentTaskTCBUnsafe() pxCurrentTCBs[ portGET_CORE_ID() ] #define prvGetCurrentTaskTCBUnsafe() pxCurrentTCBs[ portGET_CORE_ID() ]
#define prvSetCurrentTaskTCBUnsafe( pxTCB ) \
do{ \
pxCurrentTCBs[ portGET_CORE_ID() ] = pxTCB; \
} while( 0 )
#endif /* if ( configNUMBER_OF_CORES == 1 ) */ #endif /* if ( configNUMBER_OF_CORES == 1 ) */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -927,7 +919,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
#if ( configRUN_MULTIPLE_PRIORITIES == 0 ) #if ( configRUN_MULTIPLE_PRIORITIES == 0 )
BaseType_t xYieldCount = 0; BaseType_t xYieldCount = 0;
TCB_t * const pxConstCurrentTCB = prvGetCurrentTaskTCBUnsafe();
#endif /* #if ( configRUN_MULTIPLE_PRIORITIES == 0 ) */ #endif /* #if ( configRUN_MULTIPLE_PRIORITIES == 0 ) */
/* This must be called from a critical section. */ /* This must be called from a critical section. */
@ -1020,13 +1011,17 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
} }
#if ( configRUN_MULTIPLE_PRIORITIES == 0 ) #if ( configRUN_MULTIPLE_PRIORITIES == 0 )
{
TCB_t * const pxConstCurrentTCB = prvGetCurrentTaskTCBUnsafe();
/* Verify that the calling core always yields to higher priority tasks. */ /* Verify that the calling core always yields to higher priority tasks. */
if( ( ( pxConstCurrentTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0U ) && if( ( ( prvGetCurrentTaskTCBUnsafe->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0U ) &&
( pxTCB->uxPriority > pxConstCurrentTCB->uxPriority ) ) ( pxTCB->uxPriority > pxConstCurrentTCB->uxPriority ) )
{ {
configASSERT( ( xYieldPendings[ portGET_CORE_ID() ] == pdTRUE ) || configASSERT( ( xYieldPendings[ portGET_CORE_ID() ] == pdTRUE ) ||
( taskTASK_IS_RUNNING( pxConstCurrentTCB ) == pdFALSE ) ); ( taskTASK_IS_RUNNING( pxConstCurrentTCB ) == pdFALSE ) );
} }
}
#endif #endif
} }
} }
@ -2083,7 +2078,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
{ {
/* There are no other tasks, or all the other tasks are in /* There are no other tasks, or all the other tasks are in
* the suspended state - make this the current task. */ * the suspended state - make this the current task. */
prvGetCurrentTaskTCBUnsafe( pxNewTCB ); pxCurrentTCB = pxNewTCB;
if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 ) if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )
{ {
@ -2106,7 +2101,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
{ {
if( pxCurrentTCB->uxPriority <= pxNewTCB->uxPriority ) if( pxCurrentTCB->uxPriority <= pxNewTCB->uxPriority )
{ {
prvSetCurrentTaskTCBUnsafe( pxNewTCB ); pxCurrentTCB = pxTCB;
} }
else else
{ {