Quality RTOS & Embedded Software

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


Loading

Padding the task stack with 0xA5

Posted by michaeln32 on January 16, 2018

Hi, At task stack Init, The stack is padding with 0xA5.

The function prvTaskCheckFreeStackSpace() seerch for 0xA5 to know the stack memory usage at any point of time.

When there is a "Pop" data from stack (data goes out from task stack), Is the data is padd back to 0xA5 ?

And if yes, Where this padding process is happened ?


Padding the task stack with 0xA5

Posted by richard_damon on January 16, 2018

No. The idea of filling with a known (and unlikely) value, is it lets you look at the stack and be able to see the 'high water mark', the maximum usage of the stack. If you want to know the current usage, you would just use the value of the stack pointer, no need to look at the contents of the stack.


Padding the task stack with 0xA5

Posted by michaeln32 on January 16, 2018

Richard Thank you very much !

So if I understand good - at system run time - it is wrong to call the function prvTaskCheckFreeStackSpace() in order to determine the current stack memory usage.

And the best way to determine the task stack current memory usage at any time is to use stack pointers like this:

Number bytes in use in stack == ( Total stack mem usage in byes - (pxTopOfStack - pxStack))


Padding the task stack with 0xA5

Posted by richard_damon on January 16, 2018

prvTaskCheckFreeStackSpace() purpose is to tell you how much excess stack space (based on current execution profile) the task has over the full run, not the amount of free space at the moment. This is the value that you generally want to monitor to adjust stack sizes for creation of the tasks.

If you want to know how much stack space you have at the moment, perhaps to decide if you can do some stack intensive operation, you would want to take the differenece of the stack pointer (either the stack pointer register to determine for the current stack, or the stack pointer in the TCB for another stack) and the maximal stack extent allowed (depends on stack growth direction),


Padding the task stack with 0xA5

Posted by michaeln32 on January 16, 2018

Ok Richard.

Thank you !


Padding the task stack with 0xA5

Posted by rtel on January 16, 2018

Michael - I recommend you invest some time in reading the free-to-download book. It doesn't yet cover the latest features, but it will give you a good grounding on using the RTOS: https://www.freertos.org/Documentation/RTOS_book.html


Padding the task stack with 0xA5

Posted by michaeln32 on January 16, 2018

Thank you Richard


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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