I know all the general registers are pushed on the stack when the an interrupts happen, but I can’t see any code that flag register are save. The assembly instruction like setl which depends on the flag register, is easy to make a wrong result when restoring from an interrupt, if the flag register is corrupted.
Share
Yes, the
(e/r)flagsregister needs to be saved across context switches like that.All interrupts (hardware and software, including exceptions) save it automatically on the stack and the
iretinstruction at the end of the ISR restores it.System calls use the same or similar mechanism and preserve the register.
Scheduling is triggered by interrupts or system calls. So, everything’s covered.