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

Task Stack Info & Profiling Features

Posted by Chris Strahm on April 30, 2009
Most RTOS give stack space info and profiling. While FreeRTOS has the stackfree function, the tskTCB record doesn't seem to retain the orignal stack space. I find it difficut to remember how much stack space I gave a task unless I go back and look it up in the code. I added that to my task.c tskTCB record and changed the prvListTaskWithinSingleList() function to report the USED space and the TOTAL space, which I think is far more useful. My console task list output now looks like this:

TaskName State Priority Stack:Used/Total TCB
=================================================
CONRTOS R 1 35/ 128 0
IDLE R 0 59/ 128 4
HTTP B 2 102/ 1024 1
Check B 2 32/ 128 3
IntVolt B 1 39/ 128 2
=================================================

I also wrote a module of profiling code using the trace functions, and created a TaskProfileList() function that spits out a similar table as shown below:

TaskName Exec/Sec CPU
=======================================
Check 1 0.00%
HTTP 100 0.78%
CONRTOS 0 0.00%
IntVolt 10 0.00%
IDLE 100 98.67%
=======================================

These kinds of tools are invaluable for any serious RTOS work. It seems like FreeRTOS should include somekind of profiling support built in. It doesn't take much code/ROM space to do this. Just a suggestion.

RE: Task Stack Info & Profiling Features

Posted by Adam Turowski on April 30, 2009
I agree. I have written some similar tools when I was involved in properiary RTOS and it proved to be exteremely useful.

But you have to remember that FreeRTOS runs on micros with very small memory footprint, so these tools should be optionally compiled by enabling them in FreeRTOSConfig.h file

RE: Task Stack Info & Profiling Features

Posted by Alain Mouette on April 30, 2009
I have one suggestion: why not put both informations on the same table?

it would make it much easyer to use and probably smaller...

I would like very much to have that... where can I find it?

Richard, can you consider including that in FreeRTOS? please?

Alain

RE: Task Stack Info & Profiling Features

Posted by mizer on April 30, 2009
Yes I too would very much like to see the source code made available for the CPU % usage. Is there a way for you to post it this forum? Or somewhere else?

Bob

RE: Task Stack Info & Profiling Features

Posted by Richard on April 30, 2009
Sounds like a good idea to (optionally) include some profiling features. I would like to see how you have done it, either posted here (formatting can be a problem) or you could send it to me at r (dot) barry (at) freertos.org.

I have done similar things using the trace macros whereby the traceTASK_SWITCHED_IN() macro is used in combination with a high frequency timer to "count" the time each task is running for. A function can then be written to either simply display the total time, or if processing overhead is not an issue display the time each task is running as a percentage.

Regards.

RE: Task Stack Info & Profiling Features

Posted by Chris Strahm on May 2, 2009
Doing the Profiling only takes a few hundred bytes of ROM on an ARM7 and minimal RAM. But I also have some other features in here such as a Performance Timer that has uSec resolution. I find it indispensible for timing routines and performance tuning. FreeRTOS doesn't do anything with the main Timer Prescale, it is set to div by 1. Much better default would be to always set this up to provide a 1MHz master clock into the main Timer Counter, and then you have a standard 1uSec resolution time base.

I also have a single file module for a stand alone Console/printf/sprintf that dumps out the task info and profiling on demand to a RS232 terminal, and also takes commands from the terminal. Does not use any lib functions so that usually saves ROM space. You can easily add custom command support also to display anything you want.

I don't think there's anyway to attach files here, and it's probably too much to stick in the msg portion. I will send Richard an email with the stuff.

RE: Task Stack Info & Profiling Features

Posted by Alain Mouette on May 15, 2009
Hi Chris, I would like to test that code too...

Could you please put that code in some public repositoty, like www.pastebin.ca so that you can add just the link here in nthe forum.

Thanks, Alain


RE: Task Stack Info & Profiling Features

Posted by Bill Yang on May 15, 2009
Hi,

I wonder how many stack space should be defined during creating a task. Does a task stack size relate to a queue size which is used in the task? for example, if I create a queue in size of 400 bytes, does it mean the task stack size must be bigger than 400 bytes? I could not find any information regarding set task stack info in FreeRTOS.org.

Also I am interested in Chris Strahm mentioned above the Task Stack Profiling and other features. I wonder if Richard got the source code. Could you please email the source code to me? Or let me know where it posted. My email address: yyang@parvus.com

Regards,
Bill Yang

RE: Task Stack Info & Profiling Features

Posted by jp_r on May 16, 2009
xQueueCreate calls pvPortMalloc which uses xHeap which is a global (whose size is defined by configTOTAL_HEAP_SIZE), so no.

You can use this function: http://www.freertos.org/uxTaskGetStackHighWaterMark.html


RE: Task Stack Info & Profiling Features

Posted by Toan Pham on June 3, 2009

I am a novice to FreeRtos. I find it very hard to keep track of size size, cpu time utilitization of each task. Many things that I do, for example, changing a priority of a task that does nothing causes
the lwip stack to fail completely. or overflowing the stack or RAM with two much dynamic memory allocation. Many times, the processor would stop working completely.

Does anyone know where I can find the source code to find out stack watermark level, and cpu profiling? I do not think i can continue developing in freertos without this tool. Please help.

Thank you.


RE: Task Stack Info & Profiling Features

Posted by Richard on June 4, 2009
http://www.freertos.org/Stacks-and-stack-overflow-checking.html
http://www.freertos.org/rtos-run-time-stats.html
http://www.freertos.org/uxTaskGetStackHighWaterMark.html
http://www.freertos.org/a00021.html#vTaskList
http://www.freertos.org/a00021.html#vTaskGetRunTimeStats

Regards.


[ 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