pub struct IrqMutex<T> {
data: UnsafeCell<T>,
locked: AtomicBool,
}Expand description
Spinlock for data shared between normal kernel code and interrupt handlers; disables interrupts while held to avoid self-deadlock.
Fields§
§data: UnsafeCell<T>§locked: AtomicBoolImplementations§
Source§impl<T> IrqMutex<T>
impl<T> IrqMutex<T>
Sourcepub fn lock(&self) -> IrqMutexGuard<'_, T>
pub fn lock(&self) -> IrqMutexGuard<'_, T>
Acquire the lock, disabling interrupts first. Returns a guard that restores IF on drop.
Sourcepub unsafe fn force_unlock(&self)
pub unsafe fn force_unlock(&self)
Release the lock without restoring the interrupt flag, for use in panic paths.
§Safety
Calling this while a live IrqMutexGuard still exists creates two concurrent
accessors to the protected data. Only call from a panic handler that halts the
CPU immediately after and never touches the data through the mutex again.
Trait Implementations§
impl<T: Send> Send for IrqMutex<T>
Safety: as long as T is [Send] (which is forced by the bound), IrqMutex can also
be send because it does not add any non-send components
impl<T: Send> Sync for IrqMutex<T>
Safety: IrqMutex is an IRQ-safe spinlock-mutex, meaning data can only be accessed
by locking it, therefore making parallel data access impossible