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

FreeRTOS Stack and Heap Size

Posted by sindhukrishna on February 11, 2015

I use TMS570 Hercules Active Safety MCUs(LS0432, LS20216, LC4357) and FreeRTOS. From the FreeRTOS website I found that the Minimum Stack Size for an MCU can be found from the Demo code. Can the Minimum and Maximum Stack size be calculated generic? So that I can use one norm to find the Stack size for a task for any MCU...

May I know the minimum heap size that can be configured as well, hoping that the maximum heap size can be the entire RAM size?

From the following link http://www.freertos.org/FAQMem.html, the context switch time calculated for one particular microcontroller was provided. I would like to know the algorithm being implemented in finding the Context Switch time...

Thanks in Advance !


FreeRTOS Stack and Heap Size

Posted by rtel on February 11, 2015

configMINIMALSTACKSIZE is only used by the kernel to set the size of the stack used by the idle task - although it is used extensively in the demo applications just for convenience. How big it needs to be depends on what the idle task is doing. The value from the demo application is, in the majority of cases at least, assuming you don't have an idle hook function defined. If you are adding your own code to the idle task though a hook function then it will need to be much bigger. If you are calling functions such as sprintf(), especially if using GCC, then it will need to be much bigger.

We really need to add the "how do I know the maximum stack size" question to the FAQ as it is asked so often. The answer is, the same way you would in any C program. Each function call nesting depth, or each stack variable you use, will add to the stack requirement. You can of course calculate it by finding the path through your code that maximises it, but (other than in safety critical applications) I have never done that - much easier to estimate - then if the stack overflow hook gets hit increase it, and if the stack overflow hook does not get hit, use uxTaskGetstackHighWaterMark() to see how much stack has never actually been used, and adjust accordingly (you can also get the high watermark from FreeRTOS kernel aware plug-ins).

The context switch time only makes sense in cpu cycles, not in real time, so turn off stack overflow protection, ensure no trace macros are defined, ensure run-time stats are not being gathered, ensure configASSERT() is not defined, then set a break point on entry of the context switch function and a break point on the end of the function and measure the difference in CPU cycles (assuming that information is given to you by your development environment - otherwise you will have to count yourself, and that will take a long time).

Regards.


FreeRTOS Stack and Heap Size

Posted by sindhukrishna on February 12, 2015

Thanks for the information... Great support...


[ 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