You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The without_interrupts() in PR #4 always enables interrupts when the closure finishes executing.
This could be problematic in libraries; a library using this function assumes that the program it is included in actually wants interrupts to be disabled, or even if interrupts were already disabled before the call to without_interrupts
We should make a copy of the the interrupt flag in the status register, and then restore the interrupt flag back to its previous state, not just re-enabled it.
The text was updated successfully, but these errors were encountered:
One thing that I think would be very interesting to explore would be to see if we could track the state of the interrupt flag via compile-time information. For example:
// This trait is not correct, but shows a general sketch of how it might look.traitInterruptState{fnwith_interrupts<R>(self,f:implFnOnce() -> R) -> R;fnwithout_interrupts<R>(self,f:implFnOnce() -> R) -> R;}structInterruptsDisabled;implInterruptStateforInterruptsDisabled{fnwith_interrupts<R>(self,f:implFnOnce() -> R) -> R{// set registerlet x = f();// unset register
x
}fnwithout_interrupts<R>(self,f:implFnOnce() -> R) -> R{f()}}structInterruptsEnabled;// dittostructInterruptsUnknown;// ditto
When we don't know the state, we use InterruptsUnknown which gets the current state. A obsessive program could thread this through everywhere, since IIRC we start the machine with interrupts in a known state.
The
without_interrupts()
in PR #4 always enables interrupts when the closure finishes executing.This could be problematic in libraries; a library using this function assumes that the program it is included in actually wants interrupts to be disabled, or even if interrupts were already disabled before the call to
without_interrupts
We should make a copy of the the interrupt flag in the status register, and then restore the interrupt flag back to its previous state, not just re-enabled it.
The text was updated successfully, but these errors were encountered: