@@ -1134,16 +1134,31 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
11341134
11351135 if ( ( uxCoreMap & ( ( UBaseType_t ) 1U << ( UBaseType_t ) xCoreID ) ) != 0U )
11361136 {
1137- /* The ready task that was removed from this core is not excluded from it.
1138- * Only look at the intersection of the cores the removed task is allowed to run
1139- * on with the cores that the new task is excluded from. It is possible that the
1140- * new task was only placed onto this core because it is excluded from another.
1141- * Check to see if the previous task could run on one of those cores. */
1137+ /* pxPreviousTCB was removed from this core and this core is not excluded
1138+ * from it's core affinity mask.
1139+ *
1140+ * pxPreviousTCB is preempted by the new higher priority task
1141+ * pxCurrentTCBs[ xCoreID ]. When searching a new core for pxPreviousTCB,
1142+ * we do not need to look at the cores on which pxCurrentTCBs[ xCoreID ]
1143+ * is allowed to run. The reason is - when more than one cores are
1144+ * eligible for an incoming task, we preempt the core with the minimum
1145+ * priority task. Because this core (i.e. xCoreID) was preempted for
1146+ * pxCurrentTCBs[ xCoreID ], this means that all the others cores
1147+ * where pxCurrentTCBs[ xCoreID ] can run, are running tasks with priority
1148+ * no lower than pxPreviousTCB's priority. Therefore, the only cores where
1149+ * which can be preempted for pxPreviousTCB are the ones where
1150+ * pxCurrentTCBs[ xCoreID ] is not allowed to run (and obviously,
1151+ * pxPreviousTCB is allowed to run).
1152+ *
1153+ * This is an optimization which reduces the number of cores needed to be
1154+ * searched for pxPreviousTCB to run. */
11421155 uxCoreMap &= ~( pxCurrentTCBs [ xCoreID ]-> uxCoreAffinityMask );
11431156 }
11441157 else
11451158 {
1146- /* The ready task that was removed from this core is excluded from it. */
1159+ /* pxPreviousTCB's core affinity mask is changed and it is no longer
1160+ * allowed to run on this core. Searching all the cores in pxPreviousTCB's
1161+ * new core affinity mask to find a core on which it can run. */
11471162 }
11481163
11491164 uxCoreMap &= ( ( 1U << configNUMBER_OF_CORES ) - 1U );
0 commit comments