uxTaskPriorityGet() 查询某个任务的优先级。vTaskPrioritySet() 改变某个任务的任务优先级。uxTaskGetSystemState() 获取系统中任务状态。vTaskGetInfo() 获取某个任务信息。xTaskGetApplicationTaskTag() 获取某个任务的标签(Tag)值。xTaskGetCurrentTaskHandle() 获取当前正在运行的任务的任务句柄。xTaskGetHandle() 根据任务名字查找某个任务的句柄xTaskGetIdleTaskHandle() 获取空闲任务的任务句柄。uxTaskGetStackHighWaterMark()获取任务的堆栈的历史剩余最小值,FreeRTOS 中叫做“高水位线”eTaskGetState() 获取某个任务的壮态,这个壮态是 eTaskState 类型。pcTaskGetName() 获取某个任务的任务名字。xTaskGetTickCount() 获取系统时间计数器值。xTaskGetTickCountFromISR() 在中断服务函数中获取时间计数器值xTaskGetSchedulerState() 获取任务调度器的壮态,开启或未开启。uxTaskGetNumberOfTasks() 获取当前系统中存在的任务数量。vTaskList()以一种表格的形式输出当前系统中所有任务的详细信息。vTaskGetRunTimeStats() 获取每个任务的运行时间。vTaskSetApplicationTaskTag() 设置任务标签(Tag)值。SetThreadLocalStoragePointer() 设置线程本地存储指针GetThreadLocalStoragePointer() 获取线程本地存储指针
1-任务标签获取(xTaskGetApplicationTaskTag)
1.1 函数说明
TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTaskGetApplicationTaskTagFromISR);
TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
configUSE_APPLICATION_TASK_TAG必须设置为1
xTaskGetApplicationTaskTagFromISR是在中断服务中调用的另一个版本。
1.2 参数描述
xTask :正在查询任务的句柄。任务可以使用NULL作为参数值查询自己的标记值。
1.3 用例
/* In this example, an integer is set as the task tag value. */void vATask( void *pvParameters ){ /* Assign a tag value of 1 to the currently executing task. The (void *) cast is used to prevent compiler warnings. */ vTaskSetApplicationTaskTag( NULL, ( void * ) 1 ); for( ;; ) { /* Rest of task code goes here. */ }} void vAFunction( void ){TaskHandle_t xHandle;int iReturnedTaskHandle; /* Create a task from the vATask() function, storing the handle to the created task in the xTask variable. */ /* Create the task. */ if( xTaskCreate( vATask, /* Pointer to the function that implements the task. */ "Demo task", /* Text name given to the task. */ STACK_SIZE, /* The size of the stack that should be created for the task. This is defined in words, not bytes. */ NULL, /* The task does not use the parameter. */ TASK_PRIORITY, /* The priority to assign to the newly created task. */ &xHandle /* The handle to the task being created will be placed in xHandle. */ ) == pdPASS ) { /* The task was created successfully. Delay for a short period to allow the task to run. */ vTaskDelay( 100 ); /* What tag value is assigned to the task? The returned tag value is stored in an integer, so cast to an integer to prevent compiler warnings. */ iReturnedTaskHandle = ( int ) xTaskGetApplicationTaskTag( xHandle ); }}
2- 当前任务句柄获取(xTaskGetCurrentTaskHandle)
2.1 函数描述
TaskHandle_t xTaskGetCurrentTaskHandle( void );
INCLUDE_xTaskGetCurrentTaskHandle 必须设置为 1 才能使用此函数。
2.2 函数描述
Returns:
当前正在运行(调用)任务的句柄。