FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [February 2009 Threads] thread profilingPosted 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 profilingPosted 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 profilingPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|