@@ -254,8 +254,9 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
254254 BaseType_t xPreemptionDisable ; /*< Used to prevent the task from being preempted */
255255 #endif
256256
257- #if ( configUSE_CORE_EXCLUSION == 1 )
258- UBaseType_t uxCoreExclude ; /*< Used to exclude the task from certain cores */
257+ #if ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 )
258+ UBaseType_t uxCoreAffinityMask ; /*< Used to link the task to certain cores. UBaseType_t must have >= the same number of bits as SMP confNUM_CORES */
259+ UBaseType_t uxCoreAffinityInheritanceMask ; /*< Used to allow a task to inherit the affinity of its parent */
259260 #endif
260261
261262 #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
@@ -321,7 +322,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
321322 #if ( configUSE_POSIX_ERRNO == 1 )
322323 int iTaskErrno ;
323324 #endif
324- } tskTCB ;
325+ } tskTCB ;
325326
326327/* The old tskTCB name is maintained above then typedefed to the new TCB_t name
327328 * below to enable the use of older kernel aware debuggers. */
@@ -760,8 +761,8 @@ static void prvYieldForTask( TCB_t * pxTCB,
760761 {
761762 if ( xTaskPriority <= xLowestPriority )
762763 {
763- #if ( configUSE_CORE_EXCLUSION == 1 )
764- if ( ( pxTCB -> uxCoreExclude & ( 1 << x ) ) == 0 )
764+ #if ( configUSE_CORE_AFFINITY == 1 )
765+ if ( ( pxTCB -> uxCoreAffinityMask & ( 1 << x ) ) == 1 )
765766 #endif
766767 {
767768 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
@@ -824,7 +825,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
824825 BaseType_t xTaskScheduled = pdFALSE ;
825826 BaseType_t xDecrementTopPriority = pdTRUE ;
826827
827- #if ( configUSE_CORE_EXCLUSION == 1 )
828+ #if ( configUSE_CORE_AFFINITY == 1 )
828829 TCB_t * pxPreviousTCB = NULL ;
829830 #endif
830831 #if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
@@ -892,13 +893,13 @@ static void prvYieldForTask( TCB_t * pxTCB,
892893
893894 if ( pxTCB -> xTaskRunState == taskTASK_NOT_RUNNING )
894895 {
895- #if ( configUSE_CORE_EXCLUSION == 1 )
896- if ( ( pxTCB -> uxCoreExclude & ( 1 << xCoreID ) ) == 0 )
896+ #if ( configUSE_CORE_AFFINITY == 1 )
897+ if ( ( pxTCB -> uxCoreAffinityMask & ( 1 << xCoreID ) ) == 1 )
897898 #endif
898899 {
899900 /* If the task is not being executed by any core swap it in */
900901 pxCurrentTCBs [ xCoreID ]-> xTaskRunState = taskTASK_NOT_RUNNING ;
901- #if ( configUSE_CORE_EXCLUSION == 1 )
902+ #if ( configUSE_CORE_AFFINITY == 1 )
902903 pxPreviousTCB = pxCurrentTCBs [ xCoreID ];
903904 #endif
904905 pxTCB -> xTaskRunState = ( TaskRunning_t ) xCoreID ;
@@ -909,8 +910,8 @@ static void prvYieldForTask( TCB_t * pxTCB,
909910 else if ( pxTCB == pxCurrentTCBs [ xCoreID ] )
910911 {
911912 configASSERT ( ( pxTCB -> xTaskRunState == xCoreID ) || ( pxTCB -> xTaskRunState == taskTASK_YIELDING ) );
912- #if ( configUSE_CORE_EXCLUSION == 1 )
913- if ( ( pxTCB -> uxCoreExclude & ( 1 << xCoreID ) ) == 0 )
913+ #if ( configUSE_CORE_AFFINITY == 1 )
914+ if ( ( pxTCB -> uxCoreAffinityMask & ( 1 << xCoreID ) ) == 1 )
914915 #endif
915916 {
916917 /* The task is already running on this core, mark it as scheduled */
@@ -974,12 +975,12 @@ static void prvYieldForTask( TCB_t * pxTCB,
974975 }
975976 #endif /* if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) ) */
976977
977- #if ( configUSE_CORE_EXCLUSION == 1 )
978+ #if ( configUSE_CORE_AFFINITY == 1 )
978979 if ( ( pxPreviousTCB != NULL ) && ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ pxPreviousTCB -> uxPriority ] ), & ( pxPreviousTCB -> xStateListItem ) ) != pdFALSE ) )
979980 {
980- /* A ready task was just bumped off this core. Look at the cores it is not excluded
981+ /* A ready task was just bumped off this core. Look at the cores it can run from
981982 * from to see if it is able to run on any of them */
982- UBaseType_t uxCoreMap = ~( pxPreviousTCB -> uxCoreExclude ) ;
983+ UBaseType_t uxCoreMap = pxPreviousTCB -> uxCoreAffinityMask ;
983984 BaseType_t xLowestPriority = pxPreviousTCB -> uxPriority - pxPreviousTCB -> xIsIdle ;
984985 BaseType_t xLowestPriorityCore = -1 ;
985986
@@ -990,12 +991,12 @@ static void prvYieldForTask( TCB_t * pxTCB,
990991 * on with the cores that the new task is excluded from. It is possible that the
991992 * new task was only placed onto this core because it is excluded from another.
992993 * Check to see if the previous task could run on one of those cores. */
993- uxCoreMap &= pxCurrentTCBs [ xCoreID ]-> uxCoreExclude ;
994+ uxCoreMap &= ~( pxCurrentTCBs [ xCoreID ]-> uxCoreAffinityMask ) ;
994995 }
995996 else
996997 {
997998 /* The ready task that was removed from this core is excluded from it.
998- * See if we can schedule it on any of the cores where it is not excluded from. */
999+ * @todo See if we can schedule it on any of the cores where it is not excluded from. */
9991000 }
10001001
10011002 uxCoreMap &= ( ( 1 << configNUM_CORES ) - 1 );
@@ -1027,7 +1028,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
10271028 prvYieldCore ( xLowestPriorityCore );
10281029 }
10291030 }
1030- #endif /* if ( configUSE_CORE_EXCLUSION == 1 ) */
1031+ #endif /* if ( configUSE_CORE_AFFINITY == 1 ) */
10311032
10321033 return pdTRUE ;
10331034 }
@@ -1047,8 +1048,6 @@ static void prvYieldForTask( TCB_t * pxTCB,
10471048#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
10481049/*-----------------------------------------------------------*/
10491050
1050-
1051-
10521051#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
10531052
10541053 TaskHandle_t xTaskCreateStatic ( TaskFunction_t pxTaskCode ,
@@ -1078,6 +1077,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
10781077
10791078 if ( ( pxTaskBuffer != NULL ) && ( puxStackBuffer != NULL ) )
10801079 {
1080+ prvTaskCreator ( pxTaskCode , ulStack )
10811081 /* The memory used for the task's TCB and stack are passed into this
10821082 * function - use them. */
10831083 pxNewTCB = ( TCB_t * ) pxTaskBuffer ; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
@@ -1481,9 +1481,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
14811481 }
14821482 #endif
14831483
1484- #if ( configUSE_CORE_EXCLUSION == 1 )
1484+ #if ( configUSE_CORE_AFFINITY == 1 )
14851485 {
1486- pxNewTCB -> uxCoreExclude = 0 ;
1486+ pxNewTCB -> uxCoreAffinityMask = tskNO_AFFINITY ;
14871487 }
14881488 #endif
14891489 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
@@ -1608,9 +1608,9 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
16081608 if ( pxCurrentTCBs [ xCoreID ] == NULL )
16091609 {
16101610 pxNewTCB -> xTaskRunState = xCoreID ;
1611- #if ( configUSE_CORE_EXCLUSION == 1 )
1611+ #if ( configUSE_CORE_AFFINITY == 1 )
16121612 {
1613- pxNewTCB -> uxCoreExclude = ~ ( 1 << xCoreID );
1613+ pxNewTCB -> uxCoreAffinityMask = ( 1 << xCoreID );
16141614 }
16151615 #endif
16161616 pxCurrentTCBs [ xCoreID ] = pxNewTCB ;
@@ -2220,10 +2220,10 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
22202220#endif /* INCLUDE_vTaskPrioritySet */
22212221/*-----------------------------------------------------------*/
22222222
2223- #if ( configUSE_CORE_EXCLUSION == 1 )
2223+ #if ( configUSE_CORE_AFFINITY == 1 )
22242224
2225- void vTaskCoreExclusionSet ( const TaskHandle_t xTask ,
2226- UBaseType_t uxCoreExclude )
2225+ void vTaskCoreAffinitySet ( const TaskHandle_t xTask ,
2226+ UBaseType_t uxCoreAffinityMask )
22272227 {
22282228 TCB_t * pxTCB ;
22292229 BaseType_t xCoreID ;
@@ -2232,15 +2232,15 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
22322232 {
22332233 pxTCB = prvGetTCBFromHandle ( xTask );
22342234
2235- pxTCB -> uxCoreExclude = uxCoreExclude ;
2235+ pxTCB -> uxCoreAffinityMask = uxCoreAffinityMask ;
22362236
22372237 if ( xSchedulerRunning != pdFALSE )
22382238 {
22392239 if ( taskTASK_IS_RUNNING ( pxTCB -> xTaskRunState ) )
22402240 {
22412241 xCoreID = ( BaseType_t ) pxTCB -> xTaskRunState ;
22422242
2243- if ( ( uxCoreExclude & ( 1 << xCoreID ) ) != 0 )
2243+ if ( ( uxCoreAffinityMask & ( 1 << xCoreID ) ) != 1 )
22442244 {
22452245 prvYieldCore ( xCoreID );
22462246 }
@@ -2250,27 +2250,27 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
22502250 taskEXIT_CRITICAL ();
22512251 }
22522252
2253- #endif /* configUSE_CORE_EXCLUSION */
2253+ #endif /* configUSE_CORE_AFFINITY */
22542254/*-----------------------------------------------------------*/
22552255
2256- #if ( configUSE_CORE_EXCLUSION == 1 )
2256+ #if ( configUSE_CORE_AFFINITY == 1 )
22572257
2258- UBaseType_t vTaskCoreExclusionGet ( const TaskHandle_t xTask )
2258+ UBaseType_t vTaskCoreAffinityGet ( const TaskHandle_t xTask )
22592259 {
22602260 TCB_t * pxTCB ;
2261- UBaseType_t uxCoreExclude ;
2261+ UBaseType_t uxCoreAffinityMask ;
22622262
22632263 taskENTER_CRITICAL ();
22642264 {
22652265 pxTCB = prvGetTCBFromHandle ( xTask );
2266- uxCoreExclude = pxTCB -> uxCoreExclude ;
2266+ uxCoreAffinityMask = pxTCB -> uxCoreAffinityMask ;
22672267 }
22682268 taskEXIT_CRITICAL ();
22692269
2270- return uxCoreExclude ;
2270+ return uxCoreAffinityMask ;
22712271 }
22722272
2273- #endif /* configUSE_CORE_EXCLUSION */
2273+ #endif /* configUSE_CORE_AFFINITY */
22742274/*-----------------------------------------------------------*/
22752275
22762276#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
@@ -2451,8 +2451,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
24512451 BaseType_t xReturn = pdFALSE ;
24522452 const TCB_t * const pxTCB = xTask ;
24532453
2454- /* Accesses xPendingReadyList so must be called from a critical
2455- * section. */
2454+ /* Accesses xPendingReadyList so must be called from a critical section. */
24562455
24572456 /* It does not make sense to check if the calling task is suspended. */
24582457 configASSERT ( xTask );
0 commit comments