Struct ruspiro_lock::sync::Spinlock [−][src]
#[repr(C, align(16))]pub struct Spinlock { /* fields omitted */ }
Expand description
A blocking cross core lock to guarantee mutual exclusive access. While this lock might block other cores to continue processing this lock should be held as short as possible. Also care shall be taken while using this lock within interrupt handlers, as this might lead to deadlock situations if the lock holding core is interrupted and the interrupt is also trying to aquire the same lock.
Implementations
Create a new Spinlock. To ensure it is shared between cores, it’s typically assigned to a static variable
Example
static LOCK: Spinlock = Spinlock::new();
Aquire a spinlock. This will block the current core until the lock could be aquired.
Example
static LOCK: Spinlock = Spinlock::new();
LOCK.aquire();
// execution continues only if the lock could be aquired