@@ -3107,10 +3107,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
3107
3107
{
3108
3108
TCB_t * pxTCB ;
3109
3109
3110
- #if ( configNUMBER_OF_CORES > 1 )
3111
- BaseType_t xTaskRunningOnCore ;
3112
- #endif
3113
-
3114
3110
traceENTER_vTaskSuspend ( xTaskToSuspend );
3115
3111
3116
3112
taskENTER_CRITICAL ();
@@ -3121,10 +3117,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
3121
3117
3122
3118
traceTASK_SUSPEND ( pxTCB );
3123
3119
3124
- #if ( configNUMBER_OF_CORES > 1 )
3125
- xTaskRunningOnCore = pxTCB -> xTaskRunState ;
3126
- #endif
3127
-
3128
3120
/* Remove task from the ready/delayed list and place in the
3129
3121
* suspended list. */
3130
3122
if ( uxListRemove ( & ( pxTCB -> xStateListItem ) ) == ( UBaseType_t ) 0 )
@@ -3164,26 +3156,25 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
3164
3156
}
3165
3157
#endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
3166
3158
}
3159
+ taskEXIT_CRITICAL ();
3167
3160
3168
- #if ( configNUMBER_OF_CORES == 1 )
3161
+ if ( xSchedulerRunning != pdFALSE )
3169
3162
{
3170
- taskEXIT_CRITICAL ();
3171
-
3172
- if ( xSchedulerRunning != pdFALSE )
3173
- {
3174
- /* Reset the next expected unblock time in case it referred to the
3175
- * task that is now in the Suspended state. */
3176
- taskENTER_CRITICAL ();
3177
- {
3178
- prvResetNextTaskUnblockTime ();
3179
- }
3180
- taskEXIT_CRITICAL ();
3181
- }
3182
- else
3163
+ /* Reset the next expected unblock time in case it referred to the
3164
+ * task that is now in the Suspended state. */
3165
+ taskENTER_CRITICAL ();
3183
3166
{
3184
- mtCOVERAGE_TEST_MARKER ();
3167
+ prvResetNextTaskUnblockTime ();
3185
3168
}
3169
+ taskEXIT_CRITICAL ();
3170
+ }
3171
+ else
3172
+ {
3173
+ mtCOVERAGE_TEST_MARKER ();
3174
+ }
3186
3175
3176
+ #if ( configNUMBER_OF_CORES == 1 )
3177
+ {
3187
3178
if ( pxTCB == pxCurrentTCB )
3188
3179
{
3189
3180
if ( xSchedulerRunning != pdFALSE )
@@ -3218,47 +3209,39 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
3218
3209
}
3219
3210
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
3220
3211
{
3221
- if ( xSchedulerRunning != pdFALSE )
3222
- {
3223
- /* Reset the next expected unblock time in case it referred to the
3224
- * task that is now in the Suspended state. */
3225
- prvResetNextTaskUnblockTime ();
3226
- }
3227
- else
3228
- {
3229
- mtCOVERAGE_TEST_MARKER ();
3230
- }
3231
-
3232
- if ( taskTASK_IS_RUNNING ( pxTCB ) == pdTRUE )
3212
+ /* Enter critical section here to check run state of a task. */
3213
+ taskENTER_CRITICAL ();
3233
3214
{
3234
- if ( xSchedulerRunning != pdFALSE )
3215
+ if ( taskTASK_IS_RUNNING ( pxTCB ) == pdTRUE )
3235
3216
{
3236
- if ( xTaskRunningOnCore == ( BaseType_t ) portGET_CORE_ID () )
3217
+ if ( xSchedulerRunning != pdFALSE )
3237
3218
{
3238
- /* The current task has just been suspended. */
3239
- configASSERT ( uxSchedulerSuspended == 0 );
3240
- vTaskYieldWithinAPI ();
3219
+ if ( pxTCB -> xTaskRunState == ( BaseType_t ) portGET_CORE_ID () )
3220
+ {
3221
+ /* The current task has just been suspended. */
3222
+ configASSERT ( uxSchedulerSuspended == 0 );
3223
+ vTaskYieldWithinAPI ();
3224
+ }
3225
+ else
3226
+ {
3227
+ prvYieldCore ( pxTCB -> xTaskRunState );
3228
+ }
3241
3229
}
3242
3230
else
3243
3231
{
3244
- prvYieldCore ( xTaskRunningOnCore );
3232
+ /* This code path is not possible because only Idle tasks are
3233
+ * assigned a core before the scheduler is started ( i.e.
3234
+ * taskTASK_IS_RUNNING is only true for idle tasks before
3235
+ * the scheduler is started ) and idle tasks cannot be
3236
+ * suspended. */
3237
+ mtCOVERAGE_TEST_MARKER ();
3245
3238
}
3246
3239
}
3247
3240
else
3248
3241
{
3249
- /* This code path is not possible because only Idle tasks are
3250
- * assigned a core before the scheduler is started ( i.e.
3251
- * taskTASK_IS_RUNNING is only true for idle tasks before
3252
- * the scheduler is started ) and idle tasks cannot be
3253
- * suspended. */
3254
3242
mtCOVERAGE_TEST_MARKER ();
3255
3243
}
3256
3244
}
3257
- else
3258
- {
3259
- mtCOVERAGE_TEST_MARKER ();
3260
- }
3261
-
3262
3245
taskEXIT_CRITICAL ();
3263
3246
}
3264
3247
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
0 commit comments