rtel wrote on Thursday, April 18, 2013:
This (extremely old) port is explained in on the following (extremely old) web pages. I have only linked to the two relevant pages:
SREG is saved and restored as part of the task context. When a task that is switched out from an interrupt is next executed it will be switched back into the interrupt (from exactly where it was switched out) - where it will execute its end of interrupt code setting SREG back to its required value. Likewise if a task is switched in from inside an interrupt it will start executing from wherever it was switched out - which may or may not be in an interrupt but its SREG will also be correct for wherever it ends up.