Sunday, August 25, 2019

[Study FreeRTOS-API] 2.23 uxTaskPriorityGet( )

#include "FreeRTOS.h"
#include "task.h"

UBaseType_t uxTaskPriorityGet(TaskHandle_t pxTask);

Summary
Queries the priority assigned to a task at the time uxTaskPriorityGet() is called.

Parameters
pxTask  The handle of the task being queried (the subject task). 
To obtain a task’s handle create the task using xTaskCreate() and make use of the 
pxCreatedTask parameter, or create the task using xTaskCreateStatic() and store 
the returned value, or use the task’s name in a call to xTaskGetHandle().
A task may query its own priority by passing NULL in place of a valid task handle.

Return Values
The value returned is the priority of the task being queried at the time uxTaskPriorityGet() is 
called. 


Example 
void vAFunction( void )
{
TaskHandle_t xHandle;
UBaseType_t uxCreatedPriority, uxOurPriority;

/* Create a task, storing the handle of the created task in xHandle. */
if( xTaskCreate( vTaskCode, 
"Demo task", 
STACK_SIZE, NULL, PRIORITY, 
&xHandle 
) != pdPASS )
{
/* The task was not created successfully. */
}
else
{
/* Use the handle to query the priority of the created task. */
uxCreatedPriority = uxTaskPriorityGet( xHandle );

/* Query the priority of the calling task by using NULL in place of a valid task handle. */
uxOurPriority = uxTaskPriorityGet( NULL );
/* Is the priority of this task higher than the priority of the task just created? */
if( uxOurPriority > uxCreatedPriority )
{
/* Yes. */
}
}

No comments:

Post a Comment

Back to Top