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

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