mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
code refine
This commit is contained in:
parent
4ec5b9d94d
commit
cb0b1ed882
46
tasks.c
46
tasks.c
|
@ -348,6 +348,29 @@
|
|||
} \
|
||||
} while( 0 )
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#define prvGetCurrentTaskTCB() pxCurrentTCB
|
||||
#define prvGetCurrentTaskTCBUnsafe() pxCurrentTCB
|
||||
#define prvSetCurrentTaskTCBUnsafe( pxTCB ) \
|
||||
do{ \
|
||||
pxCurrentTCB = pxTCB; \
|
||||
} while( 0 )
|
||||
#else
|
||||
|
||||
/* Retrieving the current task TCB in a multi-core environment involves two steps:
|
||||
* 1. Obtaining the core ID.
|
||||
* 2. Using the core ID to index the pxCurrentTCBs array.
|
||||
* If these two steps are not performed atomically, a race condition may occur.
|
||||
* To ensure atomicity, prvGetCurrentTaskTCBUnsafe() should be called in a context where
|
||||
* the core executing the task remains fixed until the operation is completed. */
|
||||
#define prvGetCurrentTaskTCBUnsafe() pxCurrentTCBs[ portGET_CORE_ID() ]
|
||||
#define prvSetCurrentTaskTCBUnsafe( pxTCB ) \
|
||||
do{ \
|
||||
pxCurrentTCBs[ portGET_CORE_ID() ] = pxTCB; \
|
||||
} while( 0 )
|
||||
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
@ -439,29 +462,6 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
|
|||
* below to enable the use of older kernel aware debuggers. */
|
||||
typedef tskTCB TCB_t;
|
||||
|
||||
/* Retrieving the current task TCB in a multi-core environment involves two steps:
|
||||
* 1. Obtaining the core ID.
|
||||
* 2. Using the core ID to index the pxCurrentTCBs array.
|
||||
* If these two steps are not performed atomically, a race condition may occur.
|
||||
* To ensure atomicity, prvGetCurrentTaskTCBUnsafe() should be called in a context where
|
||||
* the core executing the task remains fixed until the operation is completed. */
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#define prvGetCurrentTaskTCBUnsafe() pxCurrentTCB
|
||||
#define prvGetCurrentTaskTCB() pxCurrentTCB
|
||||
#define prvSetCurrentTaskTCBUnsafe( pxTCB ) \
|
||||
do{ \
|
||||
pxCurrentTCB = pxTCB; \
|
||||
} while( 0 )
|
||||
#else
|
||||
#define prvGetCurrentTaskTCBUnsafe() pxCurrentTCBs[ portGET_CORE_ID() ]
|
||||
#define prvSetCurrentTaskTCBUnsafe( pxTCB ) \
|
||||
do{ \
|
||||
pxCurrentTCBs[ portGET_CORE_ID() ] = pxTCB; \
|
||||
} while( 0 )
|
||||
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
|
||||
|
||||
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
/* MISRA Ref 8.4.1 [Declaration shall be visible] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-84 */
|
||||
|
|
Loading…
Reference in a new issue