Unlock context switch lock without potentially screwing up switch_to function

This commit is contained in:
Jeremy Soller 2016-09-18 21:05:59 -06:00
parent 36fde7c7c5
commit 1331f4103f

View file

@ -52,6 +52,7 @@ impl Context {
}
/// Switch to the next context by restoring its stack and registers
#[cold]
#[inline(never)]
#[naked]
pub unsafe fn switch_to(&mut self, next: &mut Context) {
@ -94,7 +95,12 @@ impl Context {
asm!("mov $0, rbp" : "=r"(self.rbp) : : "memory" : "intel", "volatile");
asm!("mov rbp, $0" : : "r"(next.rbp) : "memory" : "intel", "volatile");
// Unset global lock, set inside of kernel
CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
asm!("call context_switch_unlock" : : : "memory" : "intel", "volatile");
}
}
/// Unset global lock, set inside of kernel
#[no_mangle]
extern fn context_switch_unlock(){
CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
}