Quality RTOS & Embedded Software
About   Contact   Support   FAQ   Download

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs Books & Kits Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0rc2 is now available for download and comment.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists