@@ -438,7 +438,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
438
438
/*
439
439
* Selects the highest priority available task
440
440
*/
441
- static BaseType_t prvSelectHighestPriorityTask ( const BaseType_t xCoreID );
441
+ static void prvSelectHighestPriorityTask ( const BaseType_t xCoreID );
442
442
443
443
/**
444
444
* Utility task that simply returns pdTRUE if the task referenced by xTask is
@@ -819,7 +819,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
819
819
820
820
#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
821
821
822
- static BaseType_t prvSelectHighestPriorityTask ( const BaseType_t xCoreID )
822
+ static void prvSelectHighestPriorityTask ( const BaseType_t xCoreID )
823
823
{
824
824
UBaseType_t uxCurrentPriority = uxTopReadyPriority ;
825
825
BaseType_t xTaskScheduled = pdFALSE ;
@@ -832,6 +832,9 @@ static void prvYieldForTask( TCB_t * pxTCB,
832
832
BaseType_t xPriorityDropped = pdFALSE ;
833
833
#endif
834
834
835
+ /* This function should be called when scheduler is running. */
836
+ configASSERT ( xSchedulerRunning == pdTRUE );
837
+
835
838
while ( xTaskScheduled == pdFALSE )
836
839
{
837
840
#if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
@@ -947,14 +950,9 @@ static void prvYieldForTask( TCB_t * pxTCB,
947
950
}
948
951
}
949
952
950
- /* This function can get called by vTaskSuspend() before the scheduler is started.
951
- * In that case, since the idle tasks have not yet been created it is possible that we
952
- * won't find a new task to schedule. Return pdFALSE in this case. */
953
- if ( ( xSchedulerRunning == pdFALSE ) && ( uxCurrentPriority == tskIDLE_PRIORITY ) && ( xTaskScheduled == pdFALSE ) )
954
- {
955
- return pdFALSE ;
956
- }
957
-
953
+ /* Theare are configNUMBER_OF_CORES Idle tasks created when scheduler started.
954
+ * The scheduler should be able to select a task to run when uxCurrentPriority
955
+ * is tskIDLE_PRIORITY. */
958
956
configASSERT ( ( uxCurrentPriority > tskIDLE_PRIORITY ) || ( xTaskScheduled == pdTRUE ) );
959
957
uxCurrentPriority -- ;
960
958
}
@@ -1034,8 +1032,6 @@ static void prvYieldForTask( TCB_t * pxTCB,
1034
1032
}
1035
1033
#endif /* if ( configUSE_CORE_AFFINITY == 1 ) */
1036
1034
#endif /* if ( configNUM_CORES > 1 ) */
1037
-
1038
- return pdTRUE ;
1039
1035
}
1040
1036
1041
1037
#else /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
@@ -2480,45 +2476,23 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
2480
2476
{
2481
2477
prvYieldCore ( xTaskRunningOnCore );
2482
2478
}
2483
-
2484
- taskEXIT_CRITICAL ();
2485
2479
}
2486
2480
else
2487
2481
{
2488
- taskEXIT_CRITICAL ();
2489
-
2490
- configASSERT ( pxTCB == pxCurrentTCBs [ xTaskRunningOnCore ] );
2491
-
2492
- /* The scheduler is not running, but the task that was pointed
2493
- * to by pxCurrentTCB has just been suspended and pxCurrentTCB
2494
- * must be adjusted to point to a different task. */
2495
- if ( listCURRENT_LIST_LENGTH ( & xSuspendedTaskList ) == uxCurrentNumberOfTasks ) /*lint !e931 Right has no side effect, just volatile. */
2496
- {
2497
- /* No other tasks are ready, so set the core's TCB back to
2498
- * NULL so when the next task is created the core's TCB will
2499
- * be able to be set to point to it no matter what its relative
2500
- * priority is. */
2501
- pxTCB -> xTaskRunState = taskTASK_NOT_RUNNING ;
2502
- pxCurrentTCBs [ xTaskRunningOnCore ] = NULL ;
2503
- }
2504
- else
2505
- {
2506
- /* Attempt to switch in a new task. This could fail since the idle tasks
2507
- * haven't been created yet. If it does then set the core's TCB back to
2508
- * NULL. */
2509
- if ( prvSelectHighestPriorityTask ( xTaskRunningOnCore ) == pdFALSE )
2510
- {
2511
- pxTCB -> xTaskRunState = taskTASK_NOT_RUNNING ;
2512
- pxCurrentTCBs [ xTaskRunningOnCore ] = NULL ;
2513
- }
2514
- }
2482
+ /* This code path is not possible because only Idle tasks are
2483
+ * assigned a core before the scheduler is started ( i.e.
2484
+ * taskTASK_IS_RUNNING is only true for idle tasks before
2485
+ * the scheduler is started ) and idle tasks cannot be
2486
+ * suspended. */
2487
+ mtCOVERAGE_TEST_MARKER ();
2515
2488
}
2516
2489
}
2517
2490
else
2518
2491
{
2519
- taskEXIT_CRITICAL ();
2492
+ mtCOVERAGE_TEST_MARKER ();
2520
2493
}
2521
- } /* taskEXIT_CRITICAL() - already exited in one of three cases above */
2494
+ }
2495
+ taskEXIT_CRITICAL ();
2522
2496
}
2523
2497
2524
2498
#endif /* INCLUDE_vTaskSuspend */
@@ -3940,7 +3914,7 @@ void vTaskSwitchContext( BaseType_t xCoreID )
3940
3914
3941
3915
/* Select a new task to run using either the generic C or port
3942
3916
* optimised asm code. */
3943
- ( void ) prvSelectHighestPriorityTask ( xCoreID );
3917
+ prvSelectHighestPriorityTask ( xCoreID );
3944
3918
traceTASK_SWITCHED_IN ();
3945
3919
3946
3920
/* After the new task is switched in, update the global errno. */
0 commit comments