Cygnal port – portENTER_CRITICAL

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.

Cygnal port – portENTER_CRITICAL

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.