[Task Control]

task. h
TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ); TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );

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

xTaskGetApplicationTaskTagFromISR() is a version of xTaskGetApplicationTaskTag() that can be called from an interrupt service routine (ISR).

Returns the ‘tag’ value associated with a task. The meaning and use of the tag value is defined by the application writer. The RTOS kernel itself will not normally access the tag value.

This function is intended for advanced users only.

xTask The handle of the task being queried. A task can query its own tag value by using NULL as the parameter value.
The ‘tag’ value of the task being queried.
Example usage:
/* 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 ); } }

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

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo & Nuvoton Cortex-M23 demo & STM32H745 dual core (AMP) demo.

New Updates to MIT licensed IoT MQTT and POSIX libraries are now available. New library IoT HTTPS is available.  Includes demo projects.

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


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