#spin-lock #arce-os #no-irq

no-std kspin

Spinlocks used for kernel space that can disable preemption or IRQs in the critical section

3 unstable releases

0.3.1 Apr 2, 2026
0.2.0 Apr 3, 2026
0.1.1 Aug 5, 2025
0.1.0 Jul 17, 2024

#240 in Operating systems

Download history 759/week @ 2026-01-21 1071/week @ 2026-01-28 1585/week @ 2026-02-04 1263/week @ 2026-02-11 932/week @ 2026-02-18 1387/week @ 2026-02-25 1922/week @ 2026-03-04 2117/week @ 2026-03-11 1917/week @ 2026-03-18 1357/week @ 2026-03-25 1619/week @ 2026-04-01 2942/week @ 2026-04-08 3480/week @ 2026-04-15 3100/week @ 2026-04-22 1992/week @ 2026-04-29 3475/week @ 2026-05-06

12,564 downloads per month
Used in 79 crates (28 directly)

GPL-3.0-or-later OR Apache-2…

18KB
340 lines

kspin

Crates.io Docs.rs CI

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);

Dependencies

~115–470KB
~11K SLoC