From 495cb50c18e7cfadd7f1fa46bda846ad0ba681c6 Mon Sep 17 00:00:00 2001 From: Kitlith Date: Wed, 30 Oct 2019 23:27:52 -0700 Subject: [PATCH] Preform ALL checks in try_lock. Forgot to copy paste after fixing issues in lock. Doesn't seem to be used early enough to matter, but in case it ever is... --- kernel/src/sync/spin_lock.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/src/sync/spin_lock.rs b/kernel/src/sync/spin_lock.rs index 28f707975..0b5f9b4db 100644 --- a/kernel/src/sync/spin_lock.rs +++ b/kernel/src/sync/spin_lock.rs @@ -148,7 +148,10 @@ impl SpinLock { /// a guard within Some. pub fn try_lock(&self) -> Option> { use core::sync::atomic::Ordering; - if crate::i386::interrupt_service_routines::INSIDE_INTERRUPT_COUNT.load(Ordering::SeqCst) != 0 { + use crate::cpu_locals::ARE_CPU_LOCALS_INITIALIZED_YET; + use crate::i386::interrupt_service_routines::INSIDE_INTERRUPT_COUNT; + use super::INTERRUPT_DISARM; + if !INTERRUPT_DISARM.load(Ordering::SeqCst) && ARE_CPU_LOCALS_INITIALIZED_YET.load(Ordering::SeqCst) && INSIDE_INTERRUPT_COUNT.load(Ordering::SeqCst) != 0 { panic!("\ You have attempted to lock a spinlock in interrupt context. \ This is most likely a design flaw. \