Quality RTOS & Embedded Software

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




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 ]    [ 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.0 is now available for download.


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