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.
Yes, the (e/r)flags register needs to be saved across context switches like that.
All interrupts (hardware and software, including exceptions) save it automatically on the stack and the iret instruction 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With