Quality RTOS & Embedded Software

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


Loading

Task stack size?

Posted by Bill Yang on September 2, 2009
Hi,

Does any one know how to determine a stack size when I create a task? Or tell me what factors need to be consider for calculating a task stack size? I have read it from FreeRTOS web stie, but I am still not clear how. I used the demo of Cortex_LM3Sxxxxx_Keil. I tried to figure out how the demo does to determine a stack size. For example, the default configMINIMAL_STACK_SIZE is 70, but I modified it to 250. I wonder if it is a proper setting.

Also the mainBASIC_WEB_STACK_SIZE for uIP web server was set to configMINIMAL_STACK_SIZE * 3 which the original was 70*3=210. However, since I modified to 250, now it is 250*3=750. Is it waste memory space?

Any help will be appreciated.

RE: Task stack size?

Posted by William Deninger on September 2, 2009
As you know, the stack size is determined during the creation of the task. Determining stack size has never been an automated process. For instance, FreeBSD has a default of 64MB stack for each application thread, and RedHat has 10MB user, and 8kB kernel, etc... Generally, you should estimate the required stack space for each thread. If you do have any recursive calling code within your task, you will need to program them for a maximum recursion depth.

FreeRTOS does have a compile mode supporting stack overflow detection, and I plan on having it compiled in automatically with the DEBUG build.

-W

RE: Task stack size?

Posted by incrediball on September 2, 2009
You can also use the uxTaskGetStackHighWaterMark function to determine how much stack has actually been used and fine tune it. Important is that interrupts also use the stack of the task that is interrupted (although I'm not sure if all ports do this) so their usage needs to be added to the task's own usage.

RE: Task stack size?

Posted by William Deninger on September 2, 2009
Just remember that in FreeRTOS, the stack size is specified as an unsigned portSHORT, which generally means 65535 words max. -W


[ 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