Skip to content

Commit

Permalink
Preform ALL checks in try_lock.
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
kitlith committed Oct 31, 2019
1 parent f583a67 commit 495cb50
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/src/sync/spin_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ impl<T: ?Sized> SpinLock<T> {
/// a guard within Some.
pub fn try_lock(&self) -> Option<SpinLockGuard<T>> {
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. \
Expand Down

0 comments on commit 495cb50

Please sign in to comment.