Skip to main content

Module guardian

Module guardian 

Source
Expand description

Lock guardian trait : determines the guard behaviour of [SpinLock].

Two built-in implementations are provided:

  • IrqDisabled – saves RFLAGS and clears IF before acquiring the lock. Use this for data shared across CPUs (heap, VFS, IPC queues, …). This corresponds to the classic Linux spin_lock_irqsave.

  • PreemptDisabled – increments the per-CPU preemption depth without touching IF. Use this for per-CPU data that is never accessed from interrupt handlers (scheduler run-queues, per-CPU frame caches, …).

The trait is sealed so that only these two implementations exist inside the kernel crate, preventing accidental misuse.

Structs§

GuardianState
Opaque state returned by Guardian::enter and consumed by Guardian::exit.
IrqDisabled
Guardian that saves RFLAGS and disables IRQs before the lock is acquired.
PreemptDisabled
Guardian that only disables preemption, leaving IRQs untouched.

Traits§

Guardian
Determines how interrupts / preemption are handled while a SpinLock is held.