[En-Nut-Discussion] Separate interrupt stack

Oliver Schulz olischulz at web.de
Sat Jan 17 20:29:50 CET 2004


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
interrupts...

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
executed.

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?

Regards,
Oliver.




More information about the En-Nut-Discussion mailing list