diff --git a/arch/x86_64/src/context.rs b/arch/x86_64/src/context.rs index 004914d..09cca9c 100644 --- a/arch/x86_64/src/context.rs +++ b/arch/x86_64/src/context.rs @@ -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); +}