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