avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Re: [avr-chat] task/thread stack usage


From: Marek Michalkiewicz
Subject: Re: [avr-gcc-list] Re: [avr-chat] task/thread stack usage
Date: Fri, 25 Apr 2003 17:11:36 +0200
User-agent: Mutt/1.4i

On Fri, Apr 25, 2003 at 05:58:35AM -0700, Larry Barello wrote:
> My rtos, AvrX, does the same thing with a separate stack for
> interrupts.  Switching stacks slows down processing a tad, but saves a
> lot of SRAM.  It is not necessary to patch the kernel: I used the
> "naked" attribute which had the problem of not setting up a local
> frame properly (usually not a problem).  IIRC, the "noreturn"
> attribute works now with only two bytes of wasted stack storing the
> previous frame pointer, or something like that.

GCC on the SH target already supports alternate interrupt stacks:

`sp_switch'
     Use this attribute on the SH to indicate an `interrupt_handler'
     function should switch to an alternate stack.  It expects a string
     argument that names a global variable holding the address of the
     alternate stack.

          void *alt_stack;
          void f () __attribute__ ((interrupt_handler,
                                    sp_switch ("alt_stack")));

Basically it works like this: interrupt prologue saves the stack
pointer in registers, sets SP to the value of the alt_stack variable,
and pushes the old SP value on the new stack (so that SP is easily
restored in the epilogue).  All "signal" functions (running with
interrupts disabled) can share one alternate stack.  Interrupt
handlers running with interrupts enabled must have their own stacks.

I think this would be nice to have on the AVR as well - added to my
GCC 3.4 TODO list...

Marek



reply via email to

[Prev in Thread] Current Thread [Next in Thread]