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

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