From c79f308f07d714076c1b91b23c5c93cc3e93204d Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 21 Apr 2020 20:45:15 -0600 Subject: [PATCH] Unlock CONTEXT_SWITCH_LOCK after switch happens --- src/context/switch.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/context/switch.rs b/src/context/switch.rs index b776780..34fdd23 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -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 } }