[][src]Module ruspiro_lock::spinlock

Spinlock

Providing simple atomic Spinlock. This can be used to ensure cross core atomic access to data that is typically shared between them. For example MMIO mapped registers that allow access to peripherals. Please note that usage of Spinlocks on Raspberry Pi is only safe if the MMU has ben configured properly. Otherwise the cores trying to aquire a lock will just hang, even if the lock would be available to them.

Example

static LOCK: Spinlock = Spinlock::new();
 
fn main () {
    LOCK.aquire(); // will only return if the lock could be set
    // do something
 
    LOCK.release(); // releasing the lock
}

Structs

Spinlock