下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

内核
最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。

vTaskSetApplicationTaskTag
[任务控制]

task. h
void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue );

configUSE_APPLICATION_TASK_TAG 必须定义为 1,此函数才可用。 有关详细信息,请参阅 RTOS 配置文档。

可为每个任务分配“标签”值。 此值仅供应用程序使用,RTOS 内核本身无法使用此值。 RTOS 跟踪宏文档页面提供了一个很好的示例,说明了应用程序如何 使用此功能。

参数:
xTask  正在向其分配标签值的任务的句柄。 将 xTask 作为 NULL 传递会导致将标签分配给调用任务。
pxTagValue  正在分配给任务标签的值。 该值为 TaskHookFunction_t 类型,可将函数指针赋值为标签,尽管实际上可以分配任何值。 请参阅以下示例。
示例用法:
/* In this example an integer is set as the task tag value. See the RTOS trace hook macros documentation page for an example how such an assignment can be used. */ void vATask( void *pvParameters ) { /* Assign a tag value of 1 to myself. */ vTaskSetApplicationTaskTag( NULL, ( void * ) 1 ); for( ;; ) { /* Rest of task code goes here. */ } } /***********************************************/ /* In this example a callback function is being assigned as the task tag. First define the callback function - this must have type TaskHookFunction_t as per this example. */ static BaseType_t prvExampleTaskHook( void * pvParameter ) { /* Perform some action - this could be anything from logging a value, updating the task state, outputting a value, etc. */ return 0; } /* Now define the task that sets prvExampleTaskHook as its hook/tag value. This is in fact registering the task callback, as described on the xTaskCallApplicationTaskHook() documentation page. */ void vAnotherTask( void *pvParameters ) { /* Register our callback function. */ vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook ); for( ;; ) { /* Rest of task code goes here. */ } } /* As an example use of the hook (callback) we can get the RTOS kernel to call the hook function of each task that is being switched out during a reschedule. */ #define traceTASK_SWITCHED_OUT() xTaskCallApplicationTaskHook( pxCurrentTCB, 0 )





Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.