theseus-os / Theseus

Theseus is a modern OS written from scratch in Rust that explores 𝐢𝐧𝐭𝐫𝐚𝐥𝐢𝐧𝐠𝐮𝐚𝐥 𝐝𝐞𝐬𝐢𝐠𝐧: closing the semantic gap between compiler and hardware by maximally leveraging the power of language safety and affine types. Theseus aims to shift OS responsibilities like resource management into the compiler.
https://www.theseus-os.com/
MIT License
2.92k stars 172 forks source link

Save `rflags` during context switch #1036

Closed tsoutsman closed 1 year ago

tsoutsman commented 1 year ago

There are no guarantees about the value of the interrupt flag when context switching. If the context switch is voluntary, i.e. a thread called schedule, interrupts will most likely be enabled, whereas if a thread is preempted, interrupts will be disabled. But this means that if a preempted thread A switches to a thread B that voluntarily yielded, thread B will return from the call to schedule with interrupts disabled.

The AArch64 code also needs to be modified but I'll leave that to @NathanRoyer.

May also want to mark task_switch as inline(never)?