Expand description
§kspin
Spinlocks used for kernel space that can disable preemption or IRQs in the critical section.
§Cargo Features
smp
: Use in the multi-core environment. For single-core environment (without this feature), the lock state is unnecessary and optimized out. CPU can always get the lock if we follow the proper guard in use. By default, this feature is disabled.
§Examples
use kspin::{SpinNoIrq, SpinNoPreempt, SpinRaw};
let data = SpinRaw::new(());
let mut guard = data.lock();
/* critical section, does nothing while trying to lock. */
drop(guard);
let data = SpinNoPreempt::new(());
let mut guard = data.lock();
/* critical section, preemption are disabled. */
drop(guard);
let data = SpinNoIrq::new(());
let mut guard = data.lock();
/* critical section, both preemption and IRQs are disabled. */
drop(guard);
Structs§
- Base
Spin Lock - A spin lock providing mutually exclusive access to data.
- Base
Spin Lock Guard - A guard that provides mutable data access.
Type Aliases§
- Spin
NoIrq - A spin lock that disables kernel preemption and local IRQs while trying to lock, and re-enables it after unlocking.
- Spin
NoIrq Guard - A guard that provides mutable data access for
SpinNoIrq
. - Spin
NoPreempt - A spin lock that disables kernel preemption while trying to lock, and re-enables it after unlocking.
- Spin
NoPreempt Guard - A guard that provides mutable data access for
SpinNoPreempt
. - SpinRaw
- A raw spin lock that does nothing while trying to lock.
- Spin
RawGuard - A guard that provides mutable data access for
SpinRaw
.