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

Function vTaskPrioritySet

tasks.c:2057–2216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2055#if ( INCLUDE_vTaskPrioritySet == 1 )
2056
2057 void vTaskPrioritySet( TaskHandle_t xTask,
2058 UBaseType_t uxNewPriority )
2059 {
2060 TCB_t * pxTCB;
2061 UBaseType_t uxCurrentBasePriority, uxPriorityUsedOnEntry;
2062 BaseType_t xYieldRequired = pdFALSE;
2063 BaseType_t xYieldForTask = pdFALSE;
2064 BaseType_t xCoreID;
2065
2066 configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) );
2067
2068 /* Ensure the new priority is valid. */
2069 if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES )
2070 {
2071 uxNewPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U;
2072 }
2073 else
2074 {
2075 mtCOVERAGE_TEST_MARKER();
2076 }
2077
2078 taskENTER_CRITICAL();
2079 {
2080 /* If null is passed in here then it is the priority of the calling
2081 * task that is being changed. */
2082 pxTCB = prvGetTCBFromHandle( xTask );
2083
2084 traceTASK_PRIORITY_SET( pxTCB, uxNewPriority );
2085
2086 #if ( configUSE_MUTEXES == 1 )
2087 {
2088 uxCurrentBasePriority = pxTCB->uxBasePriority;
2089 }
2090 #else
2091 {
2092 uxCurrentBasePriority = pxTCB->uxPriority;
2093 }
2094 #endif
2095
2096 if( uxCurrentBasePriority != uxNewPriority )
2097 {
2098 /* The priority change may have readied a task of higher
2099 * priority than a running task. */
2100 if( uxNewPriority > uxCurrentBasePriority )
2101 {
2102 /* The priority of a task is being raised so
2103 * perform a yield for this task later. */
2104 xYieldForTask = pdTRUE;
2105 }
2106 else if( taskTASK_IS_RUNNING( pxTCB->xTaskRunState ) )
2107 {
2108 /* Setting the priority of a running task down means
2109 * there may now be another task of higher priority that
2110 * is ready to execute. */
2111 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
2112 if( pxTCB->xPreemptionDisable == pdFALSE )
2113 #endif
2114 {

Callers 1

MPU_vTaskPrioritySetFunction · 0.85

Calls 3

uxListRemoveFunction · 0.85
prvYieldCoreFunction · 0.85
prvYieldForTaskFunction · 0.85

Tested by

no test coverage detected