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


performace and increase of flash footprint of some configs

Posted by mastupristi on February 23, 2017

Hallo, I wonder about the performace decrease and increment of footprint for: ~~~ configGENERATERUNTIMESTATS configUSETRACEFACILITY configUSESTATSFORMATTINGFUNCTIONS ~~~

I run FreeRTOS on a Cortex M4 core, and I am afraid about context switch time, task wakeup latency from ISR, etc.

Those configs was added for debugging purposes only?

best regards

performace and increase of flash footprint of some configs

Posted by rtel on February 23, 2017

You can look in the source code to see where these constants are used, and their impact. A quick grep on a handful of files is all you need to do. None of the options are required. If you turn the options on then there is an impact on overhead - functionality takes code and code takes time to execute.

configGENERATERUNTIME_STATS will add an additional load and store in the context switch as the counter is read and stored (possible also an add too, can't remember).

configUSETRACEFACILITY mainly just brings in additional functions, which will normally only add code size if you use the functions. Other impact is minor.

Again configUSESTATSFORMATTING_FUNCTIONS just brings in other functions, and has dependencies on library functions. Dependencies on library functions can have a big impact on your code size, but that is a compiler issue not a FreeRTOS issue. For example, calling sprintf() with a GCC compiler that is not optimised for MCU use can bring in loads of floating point libraries which can more than double the size of your application - whereas calling the same function with a tailored version of sprintf() or a specialise embedded compiler might just add a few bytes to your code size.

performace and increase of flash footprint of some configs

Posted by mastupristi on February 26, 2017

configGENERATERUNTIMESTATS set to 1 make me to declare also ~~~ portCONFIGURETIMERFORRUNTIMESTATS() portGETRUNTIMECOUNTERVALUE() ~~~ I can use a Timer but my hw (Kinetis K64) has 16bit timers that runs @60MHz. I make it run 10 time faster than Tick timer, so I have the interrupt triggering @10KHz.

I wrote a sample program with which I could see that the statistics are collected starting from boot. Suppose that I have a high priority task that normally is idle (near 0% CPU usage). After certain condition it takes as much CPU as possible (near 100% CPU usage) for ten or more seconds, and then it switch back to idle. The stats collected starting from boot will never say that the task is consuming 100% of CPU when it runs and 0% when it is idle. Tay always give a mean of CPU usage. I wonder if it is possible, and how, make the stats behave like moving average. In other words how is possible to have an almost instantaneous estimates of CPU usage?

bast regards

performace and increase of flash footprint of some configs

Posted by rtel on February 26, 2017

Have you looked at using FreeRTOS+Trace? http://www.freertos.org/trace

performace and increase of flash footprint of some configs

Posted by mastupristi on February 26, 2017

this not help me. I want to print periodically those infos on the console UART.

best regards

performace and increase of flash footprint of some configs

Posted by heinbali01 on February 26, 2017

I'm guessing: if you were able to clear the counters of the task' CPU-times, you can make what you want?

As a temporary solution, you could do the following, based on version v9.0.0 :

~~~ tasks.c, line 3409:

#if( configUSETRACEFACILITY == 1 ) + /* When the global variable 'xTaskClearCounters' is + non-zero, the field 'ulRunTimeCounter' will be zero'd. */ + BaseType_t xTaskClearCounters;

 void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState )

tasks.c, line 3456 + 3:

     #if ( configGENERATE_RUN_TIME_STATS == 1 )
         pxTaskStatus->ulRunTimeCounter = pxTCB->ulRunTimeCounter;
  • if( xTaskClearCounters != pdFALSE )
  • {
  • pxTCB->ulRunTimeCounter = 0;
  • } } #else ~~~

( the lines starting with a + should be inserted into your copy of tasks.c )

Now you collect all CPU times, e.g. every second by calling uxTaskGetSystemState().

~~~ extern BaseType_t xTaskClearCounters;

if( time to make logging )
    xTaskClearCounters = pdTRUE;
    uxTaskGetSystemState( xTaskStatusArray, ARRAY_SIZE( xTaskStatusArray ), &ulTotalRunTime );


I would like to submit a change request, asking for the possibility to clear all counters (the field ulRunTimeCounter), and also to add a new counter called ulSwitchCounter. I would like to know how many times each task has become active. This can be helpful when tuning the power consumption of an application.


[ 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