Quality RTOS & Embedded Software

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


How to get a list of all task handles?

Posted by helliwell_cj on January 4, 2016

I'm implementing a watchdog function, whereby each task 'checks in' (to indicate it is still alive) by setting a flag/variable; the watchdog monitor periodically makes sure all the current tasks have checked in and, if so, resets the cpu watchdog time and clears the flags. I've got the mechanism basically working, but the monitor needs to know how many and/or which tasks it should expect to hear from. Currently I've used uxTaskGetSystemState(), but it's causing me to miss some UART interrupts [yes, I'm aware that this function is only recommended for debugging]. So is there a neater/faster way to get a list of task handles? I don't need much of the stuff that uxTaskGetSystemState() does (and which presumably cause the lengthy scheduler suspension) - I just need to be able to walk through the list and examine a couple of variables of each TCB.

How to get a list of all task handles?

Posted by davedoors on January 4, 2016

uxTaskGetSystemState() is the normal way, but if it is causing a problem, then how about having your tasks register with the watchdog management task when they are create? That can be done manually by the task implementer or automatically using the trace macros that execute when a task is created and deleted.

How to get a list of all task handles?

Posted by helliwell_cj on January 4, 2016

Yes, I'd starting wondering - if there's no other mechanism already there to use - about patching into the create/delete. I am using Trace functionality too though, so I'd need to wrap extra into the trace macros. Doing it 'manually' could be a bit too much of a risk [of forgetting]. I did also wonder about simply adding my own function to tasks.c - not ideal but, given that I'd need to modify the trace macros anyway, may be just as clean a solution? Bit of a headache to keep re-patching into future updates, though we won't be upgrading the RTOS too often.

How to get a list of all task handles?

Posted by helliwell_cj on January 4, 2016

Just for potentially useful info for others: uxTaskGetSystemState() is taking about ~2ms to execute on my system; with 10 tasks running. The bulk of this time is in finding the stacks' high water marks (prvTaskCheckFreeStackSpace) - commenting this out drops the execution time to ~20us.

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

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.


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


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