Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


vTaskSetApplicationTaskTag
[Task Control]

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

configUSE_APPLICATION_TASK_TAG must be defined as 1 for this function to be available. See the RTOS Configuration documentation for more information.

A 'tag' value can be assigned to each task. This value is for the use of the application only - the RTOS kernel itself does not make use of it in any way. The RTOS trace macros documentation page provides a good example of how an application might make use of this feature.

Parameters:
xTask The handle of the task to which a tag value is being assigned. Passing xTask as NULL causes the tag to be assigned to the calling task.
pxTagValue The value being assigned to the task tag. This is of type TaskHookFunction_t to permit a function pointer to be assigned as the tag, although any value can actually be assigned. See the example below.
Example usage:
/* 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 )






[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner