Quality RTOS & Embedded Software

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


Loading

How to measure task stack size?

Posted by Nobody/Anonymous on January 4, 2006
How we can evaluate the task stack size? Is there anyway to find task stack overflow?Ways to preventing this problem?

RE: How to measure task stack size?

Posted by Richard on January 4, 2006
Which processor are you using?

There are a couple of options.

Take a look at the function usTaskCheckFreeStackSpace() in tasks.c. This is what the uIP demo (http://rtosdemo3.redirectme.net) uses to print out the free stack space of every task (link will probably only work from residential computers as most office firewalls will block the nonstandard port number). Note this function disables interrupts for a while so is not a good idea other than for testing.

Secondly the TCB contains pointers to both ends of the stack, so it is easy to see if the two are getting lose. In the task context switch function you could check for this. I don't do it in the download code because obviously it increases the context switch time - but it may be a trade of you like.

Regards.

RE: How to measure task stack size?

Posted by Nobody/Anonymous on January 4, 2006
you said:
"Secondly the TCB contains pointers to both ends of the stack, so it is easy to see if the two are getting lose. In the task context switch function you could check for this. I don't do it in the download code because obviously it increases the context switch time - but it may be a trade of you like."

In debug mode using AVR Jtag,How we can it what variables I should check? where I can place breakpoint?

RE: How to measure task stack size?

Posted by Jeff Smith on January 4, 2006
CurrentStackSpace =
pxCurrentTCB->pxTopOfStack - pxCurrentTCB->pxStack;

-or-

I often wonder how full it got, not just how full it is now. My port fills 0xA5 to initialize stack space. Most often it works to start at *pxCurrentTCB->pxStack and count all the '\xa5' bytes to see how close I've been to overflowing. And it's always better to have a little more than you ever see used.

RE: How to measure task stack size?

Posted by Nobody/Anonymous on January 5, 2006
CurrentStackSpace =
pxCurrentTCB->pxTopOfStack - pxCurrentTCB->pxStack;

Assuming the stack is growing down ;-)

You can place this code immediately before the context switch.


[ 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