Crates.io | kspin |
lib.rs | kspin |
version | 0.1.0 |
source | src |
created_at | 2024-07-17 07:45:49.077527 |
updated_at | 2024-07-17 07:45:49.077527 |
description | Spinlocks used for kernel space that can disable preemption or IRQs in the critical section. |
homepage | https://github.com/arceos-org/arceos |
repository | https://github.com/arceos-org/kspin |
max_upload_size | |
id | 1305946 |
size | 18,513 |
Spinlocks used for kernel space that can disable preemption or IRQs in the critical section.
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.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);