Without re-opening the long and interesting discussion of whether RTOS's are a good idea I had a question re context saving for an AVR.
The usual approach when saving context is to save all registers plus a status register plus a return address = 35 bytes.
The problem with this approach is that a simple task might only be using a few registers but still the full 35 bytes are saved.
I have seen some discussion about the idea of scanning for non zero registers and saving used registers only. this could be done (say) by saving in groups of 4 and saving one additional byte where each bit with a 1 indicated that that 4 registers should be restored - eg b0 = r0-r3.
I was prompted to think of a much simpler idea when reading about register usage @ http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_reg_usage
I have not tested it yet but it seems to me that if we are using GCC for AVR and the context saving is done in a subroutine then we should only need to save the Call-saved registers (r2-r17, r28-r29) as the calling subroutine assumes that the Call-used registers (r18-r27, r30-r31) are clobbered and saves them explicitly if they are in use. This would ~halve stack usage for simple tasks and not increase it for complex tasks.
Does this idea make sense?
Has anyone done some experimenting with this sort of idea?