MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / prvSelectHighestPriorityTask

Function prvSelectHighestPriorityTask

tasks.c:820–1037  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
819
820 static BaseType_t prvSelectHighestPriorityTask( const BaseType_t xCoreID )
821 {
822 UBaseType_t uxCurrentPriority = uxTopReadyPriority;
823 BaseType_t xTaskScheduled = pdFALSE;
824 BaseType_t xDecrementTopPriority = pdTRUE;
825
826 #if ( configUSE_CORE_AFFINITY == 1 )
827 TCB_t * pxPreviousTCB = NULL;
828 #endif
829 #if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
830 BaseType_t xPriorityDropped = pdFALSE;
831 #endif
832
833 while( xTaskScheduled == pdFALSE )
834 {
835 #if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
836 {
837 if( uxCurrentPriority < uxTopReadyPriority )
838 {
839 /* We can't schedule any tasks, other than idle, that have a
840 * priority lower than the priority of a task currently running
841 * on another core. */
842 uxCurrentPriority = tskIDLE_PRIORITY;
843 }
844 }
845 #endif
846
847 if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxCurrentPriority ] ) ) == pdFALSE )
848 {
849 List_t * const pxReadyList = &( pxReadyTasksLists[ uxCurrentPriority ] );
850 ListItem_t * pxLastTaskItem = pxReadyList->pxIndex->pxPrevious;
851 ListItem_t * pxTaskItem = pxLastTaskItem;
852
853 if( ( void * ) pxLastTaskItem == ( void * ) &( pxReadyList->xListEnd ) )
854 {
855 pxLastTaskItem = pxLastTaskItem->pxPrevious;
856 }
857
858 /* The ready task list for uxCurrentPriority is not empty, so uxTopReadyPriority
859 * must not be decremented any further */
860 xDecrementTopPriority = pdFALSE;
861
862 do
863 {
864 TCB_t * pxTCB;
865
866 pxTaskItem = pxTaskItem->pxNext;
867
868 if( ( void * ) pxTaskItem == ( void * ) &( pxReadyList->xListEnd ) )
869 {
870 pxTaskItem = pxTaskItem->pxNext;
871 }
872
873 pxTCB = pxTaskItem->pvOwner;
874
875 /*debug_printf("Attempting to schedule %s on core %d\n", pxTCB->pcTaskName, portGET_CORE_ID() ); */
876
877 #if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )

Callers 2

vTaskSuspendFunction · 0.85
vTaskSwitchContextFunction · 0.85

Calls 3

uxListRemoveFunction · 0.85
vListInsertEndFunction · 0.85
prvYieldCoreFunction · 0.85

Tested by

no test coverage detected