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

Function prvYieldForTask

tasks.c:716–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714/*-----------------------------------------------------------*/
715
716static void prvYieldForTask( TCB_t * pxTCB,
717 const BaseType_t xPreemptEqualPriority )
718{
719 BaseType_t xLowestPriority;
720 BaseType_t xTaskPriority;
721 BaseType_t xLowestPriorityCore = -1;
722 BaseType_t xYieldCount = 0;
723 BaseType_t x;
724 TaskRunning_t xTaskRunState;
725
726 /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION */
727
728 configASSERT( pxCurrentTCB->uxCriticalNesting > 0U );
729
730 #if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
731 {
732 /* No task should yield for this one if it is a lower priority
733 * than priority level of currently ready tasks. */
734 if( pxTCB->uxPriority < uxTopReadyPriority )
735 {
736 return;
737 }
738 }
739 #endif
740
741 xLowestPriority = ( BaseType_t ) pxTCB->uxPriority;
742
743 if( xPreemptEqualPriority == pdFALSE )
744 {
745 /* xLowestPriority will be decremented to -1 if the priority of pxTCB
746 * is 0. This is ok as we will give system idle tasks a priority of -1 below. */
747 --xLowestPriority;
748 }
749
750 for( x = ( BaseType_t ) 0; x < ( BaseType_t ) configNUM_CORES; x++ )
751 {
752 /* System idle tasks are being assigned a priority of tskIDLE_PRIORITY - 1 here */
753 xTaskPriority = ( BaseType_t ) pxCurrentTCBs[ x ]->uxPriority - pxCurrentTCBs[ x ]->xIsIdle;
754 xTaskRunState = pxCurrentTCBs[ x ]->xTaskRunState;
755
756 if( ( taskTASK_IS_RUNNING( xTaskRunState ) != pdFALSE ) && ( xYieldPendings[ x ] == pdFALSE ) )
757 {
758 if( xTaskPriority <= xLowestPriority )
759 {
760 #if ( configNUM_CORES > 1 )
761 #if ( configUSE_CORE_AFFINITY == 1 )
762 if( ( pxTCB->uxCoreAffinityMask & ( 1 << x ) ) != 0 )
763 #endif
764 #endif
765 {
766 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
767 if( pxCurrentTCBs[ x ]->xPreemptionDisable == pdFALSE )
768 #endif
769 {
770 xLowestPriority = xTaskPriority;
771 xLowestPriorityCore = x;
772 }
773 }

Callers 11

prvAddNewTaskToReadyListFunction · 0.85
vTaskPrioritySetFunction · 0.85
vTaskResumeFunction · 0.85
xTaskResumeFromISRFunction · 0.85
xTaskAbortDelayFunction · 0.85
xTaskIncrementTickFunction · 0.85
xTaskRemoveFromEventListFunction · 0.85
xTaskGenericNotifyFunction · 0.85

Calls 1

prvYieldCoreFunction · 0.85

Tested by

no test coverage detected