FreeRTOS之uxTaskPriorityGet()

uxTaskPriorityGet()函數解析

task. h
UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );

總結

在調用uxTaskPriorityGet()時,查詢分配給任務的優先級。

參數

參數 功能
pxTask 正在被查詢的任務的句柄;任務可以通過在有效的任務句柄處傳遞NULL來查詢自己的優先級

返回值

返回值是在調用uxTaskPriorityGet()時查詢的任務的優先級。

使用例程

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.
     }
 }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章