Unlock CONTEXT_SWITCH_LOCK after switch happens

This commit is contained in:
Jeremy Soller
2020-04-21 20:45:15 -06:00
parent 0bfd830f3c
commit c79f308f07

View File

@@ -135,11 +135,9 @@ pub unsafe fn switch() -> bool {
CONTEXT_ID.store((*to_ptr).id, Ordering::SeqCst);
}
// Unset global lock before switch, as arch is only usable by the current CPU at this time
arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
if to_ptr as usize == 0 {
// No target was found, return
// No target was found, unset global lock and return
arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
false
} else {
@@ -158,6 +156,9 @@ 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
}
}