[En-Nut-Discussion] Separate interrupt stack

Ralph Mason ralph.mason at telogis.com
Wed Jan 21 08:18:01 CET 2004

Hi Oliver,

Good work!

I'd like to take a peak at what you have done, could you email it to me 
please. Then I can make any suggestions.

As I have said before, I don't think nested interrupts are 'right' for 
NutOS, so I don't see that as a limitation at all.  I think a preemptive 
scheduler running 'under' Nut is the right way to handle hard real time 
requirements.  I think this would be quite easy to implement (and I plan 
on doing it when I have need for it)


>Hi community,
>last year there were some discussion about a separate interrupt stack. The
>main benefit is that the stack sizes of all threads can be minimized and you
>would have more heap mem available.
>Because I'm very interessed in this topic, I wrote today this separate
>interrupt stack for avr-gcc compiler. My interrupt stack size is 256 bytes
>and it seems, that the code is stable. I tested it with several sample apps.
>If an interrupt occurs, the current thread stack is used for storing two
>bytes. Then the stack pointer is saved in a static variable. That's the
>reason, why this interrupt stack implementation is not suitable for nested
>interrupts (in this version). Fortunately Nut/OS doesn't use nested
>Then the stack pointer is switched to the interrupt stack, the important
>registers are saved and CallHandler() is executed. Upon returning from
>CallHandler, the registers are restored and the stack is switched back to
>the previously saved value. That's all.
>Because the 'interrupt' attribute is not longer used, the compiler doesn't
>generate any code itself to save registers on stack. But using the old
>function names makes sure that the intterupt functions are properly
>Again, this modification is for avr-gcc compiler only. I don't know whether
>this code can be ported to ICCAVR. Perhaps somebody with ICCAVR experience
>can think about it.
>I send a zip file with the changed and new files to Harald, please add it to
>the Projects page on www.ethernut.de
>If further testing by other people is still successfull and stable, I
>suggest to commit this interrupt stack to CVS.
>Any comment?
>En-Nut-Discussion mailing list
>En-Nut-Discussion at egnite.de

More information about the En-Nut-Discussion mailing list