Unlock CONTEXT_SWITCH_LOCK after loading registers but before switch

This commit is contained in:
Jeremy Soller
2020-04-21 21:03:17 -06:00
parent c79f308f07
commit 582e3fd8eb
2 changed files with 5 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
use core::mem;
use core::sync::atomic::AtomicBool;
use core::sync::atomic::{AtomicBool, Ordering};
use syscall::data::FloatRegisters;
/// This must be used by the kernel to ensure that context switches are done atomically
@@ -127,6 +127,7 @@ impl Context {
}
/// Switch to the next context by restoring its stack and registers
/// Check disassembly!
#[cold]
#[inline(never)]
#[naked]
@@ -167,6 +168,9 @@ 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 after loading registers but before switch
CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
}
}

View File

@@ -156,9 +156,6 @@ pub unsafe fn switch() -> bool {
(*from_ptr).arch.switch_to(&mut (*to_ptr).arch);
// Unset global lock after switch
arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
true
}
}