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

Function prvGetExpectedIdleTime

tasks.c:2891–2947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2889#if ( configUSE_TICKLESS_IDLE != 0 )
2890
2891 static TickType_t prvGetExpectedIdleTime( void )
2892 {
2893 TickType_t xReturn;
2894 UBaseType_t uxHigherPriorityReadyTasks = pdFALSE;
2895
2896 /* uxHigherPriorityReadyTasks takes care of the case where
2897 * configUSE_PREEMPTION is 0, so there may be tasks above the idle priority
2898 * task that are in the Ready state, even though the idle task is
2899 * running. */
2900 #if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
2901 {
2902 if( uxTopReadyPriority > tskIDLE_PRIORITY )
2903 {
2904 uxHigherPriorityReadyTasks = pdTRUE;
2905 }
2906 }
2907 #else
2908 {
2909 const UBaseType_t uxLeastSignificantBit = ( UBaseType_t ) 0x01;
2910
2911 /* When port optimised task selection is used the uxTopReadyPriority
2912 * variable is used as a bit map. If bits other than the least
2913 * significant bit are set then there are tasks that have a priority
2914 * above the idle priority that are in the Ready state. This takes
2915 * care of the case where the co-operative scheduler is in use. */
2916 if( uxTopReadyPriority > uxLeastSignificantBit )
2917 {
2918 uxHigherPriorityReadyTasks = pdTRUE;
2919 }
2920 }
2921 #endif /* if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) */
2922
2923 if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY )
2924 {
2925 xReturn = 0;
2926 }
2927 else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 )
2928 {
2929 /* There are other idle priority tasks in the ready state. If
2930 * time slicing is used then the very next tick interrupt must be
2931 * processed. */
2932 xReturn = 0;
2933 }
2934 else if( uxHigherPriorityReadyTasks != pdFALSE )
2935 {
2936 /* There are tasks in the Ready state that have a priority above the
2937 * idle priority. This path can only be reached if
2938 * configUSE_PREEMPTION is 0. */
2939 xReturn = 0;
2940 }
2941 else
2942 {
2943 xReturn = xNextTaskUnblockTime - xTickCount;
2944 }
2945
2946 return xReturn;
2947 }
2948

Callers 1

tasks.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected