Expand description
Generic spinlock with configurable guard behaviour.
§Choosing a guardian
SpinLock<T> → SpinLock<T, IrqDisabled> (default)
SpinLock<T, IrqDisabled> → saves RFLAGS + clears IF (equiv. spin_lock_irqsave)
SpinLock<T, PreemptDisabled> → disables preemption only, IRQs untouchedUse IrqDisabled (the default) for:
- Data shared across CPUs (heap, VFS, IPC queues, network rings, …)
- Any data touched from interrupt handlers
Use PreemptDisabled for:
- Per-CPU data never accessed from interrupt handlers (scheduler run-queues, per-CPU frame caches, statistics counters …)
All call sites that use SpinLock<T> without a type argument continue to
compile unchanged : IrqDisabled is the default guardian.
§Debug helpers
debug_set_watch_lock_addr / debug_clear_watch_lock_addr emit a serial
trace on every drop of a specific lock instance : useful when hunting
deadlocks.
Structs§
- Spin
Lock - A spinlock parameterised by a
Guardian. - Spin
Lock Guard - RAII guard that holds the lock and carries the guardian state.
Constants§
- DEBUG_
TRACE_ 🔒WATCH_ SLOTS - Maximum number of locks that can be traced simultaneously via E9 port.
Statics§
- DEBUG_
TRACE_ 🔒WATCH_ ADDRS - Fixed-size array of watched lock addresses for E9 trace. Each slot emits a unique ASCII tag (‘A’..‘H’) on acquire/release.
- DEBUG_
WATCH_ 🔒LOCK_ ADDR
Functions§
- debug_
clear_ trace_ slot - Clear a specific trace slot by index.
- debug_
clear_ watch_ lock_ addr - Clear the watched lock address.
- debug_
set_ trace_ buddy_ addr - Legacy alias: register the first available trace slot.
- debug_
set_ trace_ lock_ addr - Register a lock address for E9 trace. Returns the slot index (0..7),
or
Noneif all slots are in use. - debug_
set_ trace_ slab_ addr - Legacy alias: register the first available trace slot.
- debug_
set_ watch_ lock_ addr - Register a lock address to trace on every drop (serial console output).
- emit_
trace_ 🔒e9 - Emit an E9 byte for each matching trace slot (acquire = uppercase, release = lowercase).