FreeRTOS 之 uxTaskPriorityGet ()

uxTaskPriorityGet () function analysis

task. h
UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );

to sum up

When calling uxTaskPriorityGet (), query the priority assigned to the task.

parameter

parameter Features
pxTask The handle of the task being queried; the task can query its own priority by passing NULL at the effective task handle

return value

The return value is the priority of the task queried when uxTaskPriorityGet () is called.

Use routines

void vAFunction( void )
 {
 TaskHandle_t xHandle;

     // Create a task, storing the handle.
     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );

     // ...

     // Use the handle to obtain the priority of the created task.
     // It was created with tskIDLE_PRIORITY, but may have changed
     // it itself.
     if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
     {
         // The task has changed its priority.
     }

     // ...

     // Is our priority higher than the created task?
     if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
     {
         // Our priority (obtained using NULL handle) is higher.
     }
 }

Published 163 original articles · Liked 183 · Visit 120,000+

Guess you like

Origin blog.csdn.net/qq_31339221/article/details/102906616