Quality RTOS & Embedded Software

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


Loading

thread profiling

Posted by Eduardo Goncalves on February 9, 2009
HI :)

Does one know if it is possible to find out how much a task (or all tasks) have been running for a period of time. That is I would like to have something like:

In the last x second
Task A has run 23 ms
Task B has run 281 ms
Task C has run 0 ms
Task idle has run 900 ms
INT 1 has run 100 us
...

Any ideas?
thanks

RE: thread profiling

Posted by Dave on February 9, 2009
Take a look at this page http://www.freertos.org/rtos-trace-macros.html you can trace nearly everything.

RE: thread profiling

Posted by incrediball on February 12, 2009
As davedoors mentioned, use the trace macros. Using a hardware based timer you can accurately measure the time spent in each task.

Define the following in a header that freertos uses:

typedef struct {
#if (TRACE_TASK_EXECUTION)
volatile unsigned int task_time;
#endif
} tTaskData;

typedef tTaskData* pTaskData;

#if (TRACE_TASK_EXECUTION)
extern unsigned short task_switch_time;// timers are only 16 bit

#define HIGH_RES_TIMER(unsigned short)AT91C_BASE_TC0->TC_CV// AT91SAM7S hardware timer at 374kHz

#define traceTASK_SWITCHED_IN()task_switch_time = HIGH_RES_TIMER
#define traceTASK_SWITCHED_OUT()\
if (pxCurrentTCB->pxTaskTag)\
((pTaskData)pxCurrentTCB->pxTaskTag)->task_time += (unsigned short)(HIGH_RES_TIMER - task_switch_time);
#endif

.....

When the tasks start up, they do:

tTaskData taskdata;

vTaskSetApplicationTaskTag (NULL, (pdTASK_HOOK_CODE) &taskdata);

Then somewhere (e.g. in the idle task), regularly read out the task_time values from all your tTaskData structs. You can obviously easily get percentages by dividing each time by the total and you can get an overall system busy percentage (e.g. like in the Windows task manager) based on the idle task, i.e. if the idle task gets 100% of the time then the system is 0% busy, if the idle task only gets 5% then the system is 95% busy, etc.


[ 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