Quality RTOS & Embedded Software

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


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