Quality RTOS & Embedded Software

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


Loading

xISRStack

Posted by Joerg on July 14, 2010
Dear all @ freertos,

I need to optimize the memory-usage im my application.

As I can see the xISRStack grows from higher to lower Adresses.
Mostly I can see a "0x55AA55AA mark" on top.

Is there any specification available how the xISRStack is working and what it is used for?
Is there a way of using a watermark to see the isrStack´s behaivior or if the stack overflowed ?
Is the Compilers usual Prologe/Epiloge left unaffectted by using freeRros ?

Thank you for your reply
J .


RE: xISRStack

Posted by Dave on July 14, 2010
You would have to give a clue as to which architecture and compiler you were using.

RE: xISRStack

Posted by Joerg on July 14, 2010
Sorry,

in this particular project the PIC32MX port is used on a C32 Compiler.

J

RE: xISRStack

Posted by Richard on July 14, 2010
“Is there any specification available how the xISRStack is working and what it is used for?”


Three things make it advantageous under most circumstances to use a separate interrupt (or 'system') stack on the M4K core:

1) The M4K has a large context, that has to be saved on a task by task basis.
2) The M4K does not automatically maintain more than one stack, so each task would have to otherwise maintain a stack that was large enough to hold the entire task and interrupt context. In other words, the interrupt context size would have to be multiplied by the number of tasks you have when working out the RAM usage.
3) The MIPS ABI is not exactly designed to minimise stack usage. That is, when it generates a function call stack frame quite a lot of RAM is required.

Therefore the FreeRTOS port maintains a stack for each task onto which its own context (and no other) is saved, and xISRStack that is switched to each time an interrupt (with nesting count of zero) is accepted. xISRStack is used by the portSAVE_CONTEXT and portRESTORE_CONTEXT macros automatically and dramatically reduces the amount of RAM an application requires to execute were it not used, at the cost of a little extra code required to enter an interrupt.


“Is there a way of using a watermark to see the isrStack´s behaivior or if the stack overflowed ?”


You could easily extend the code to fill the ISR stack with a known pattern, then check this from anywhere you like to ensure the end of the stack has not been overwritten. For example, from within portSAVE_CONTEXT(), the tick interrupt hook, the traceTASK_SWITCHED_IN() macro, etc, although portSAVE_CONTEXT() would be best as this will be called on each context saving interrupt which is where the overflow would actually occur. Alternatively you could check that there is sufficient space to save the context prior to the context actually being saved, but again this would not catch all overflows, checking for a pattern being overwritten at least demonstrates a historical overflow too.


“Is the Compilers usual Prologe/Epiloge left unaffectted by using freeRros ?”


Not when using the portSAVE_CONTEXT() and portRESTORE_CONTEXT() macros. Read the "Interrupt Service Routines" section of the port documentation page: http://www.freertos.org/port_PIC32_MIPS_MK4.html

RE: xISRStack

Posted by Joerg on July 26, 2010
That clears it up for me, thank you for your extensive reply.

I have had some trouble because the Project comes from another port, were the wrapper wasn´t implemented.
It has the ability of nested interrupts but this happens not very often over time.
This explains most of the trouble I have had while porting to MK4 Kernel.

I wish I have had a close look at your "port_PIC32_MIPS_MK4.html" Document prior...

Anyway, I have checked the stack-usage by filling it with a known pattern, that save me another 300 bytes aprox.

Thank you Richard
J


[ 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