Quality RTOS & Embedded Software

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


Recommendation for stack sizes

Posted by Dan on July 27, 2007

Would it be possible to change the 'unsigned portSHORT usStackDepth;'
to 'unsigned portLONG ulStackDepth;' in struct tskTaskControlBlock?
(and update the modified references)

First, yes, I did need a stack larger than 64k variables.

2nd, being a short causes some compilers to emit slightly more code
than if the type were the natural integer size.

3rd, being a short in a structure opens up the possibilities
for problems with structure packing (although not likely an issue
with this structure yet).

Dan Searles

RE: Recommendation for stack sizes

Posted by Richard on July 27, 2007
You have been busy! Thanks for your comments and suggestions.

The stack size used to be unsigned portBASE_TYPE, but this caused problems on some 8bit systems where the stack could not be greater than 0xff. Long was considered too wasteful on 8bitters (mainly because of its use in the TCB rather than just as a function parameter), so short became the compromise. FreeRTOS.org has come a long way since then however and finds most uses in the 32bit world.


RE: Recommendation for stack sizes

Posted by David Hawks on July 27, 2007
> FreeRTOS.org...finds most uses in the 32bit world.

Really? Wow. Please don't forget about all the 8-bitters though. I still agree that "long" is too wasteful. If you make any change, perhaps you should make it configurable.

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

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.


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


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