Cygnal port - portENTER_CRITICAL

nobody wrote on Thursday, November 17, 2005:

I have a question on the portENTER_CRITICAL() and portEXIT_CRITICAL() macros in the Cygnal port (portmacro.h):
What is the reason for the pushing and popping of IE? Can’t you just disable interrupts and enable them (EA = 0 on ENTER and EA = 1 on EXIT)?

Thanks.

nobody wrote on Thursday, November 17, 2005:

Each task maintains its own interrupt state so the register must be saved.  One task may disable interrupts, but then cause a context switch.  Wile it is swapped out another task will run which may have interrupts enabled.  When the original task starts again it must start with its expected context - interrupts being disabled.