8 .Nd atomic spin lock synchronization primitives
12 .In libkern/OSAtomic.h
14 .Fn OSSpinLockTry "OSSpinLock *lock"
16 .Fn OSSpinLockLock "OSSpinLock *lock"
18 .Fn OSSpinLockUnlock "OSSpinLock *lock"
20 Spin locks are a simple, fast, thread-safe synchronization primitive that is
21 suitable in situations where contention is expected to be low. The spinlock
22 operations use memory barriers to synchronize access to shared memory protected
23 by the lock. Preemption is possible while the lock is held.
26 is an integer type. The convention is that unlocked is zero, and locked is nonzero.
27 Locks must be naturally aligned and cannot be in cache-inhibited memory.
30 will spin if the lock is already held, but employs various strategies to back off,
31 making it immune to most priority-inversion livelocks. But because it can spin, it
32 may be inefficient in some situations.
35 immediately returns false if the lock was held, true if it took the lock.
39 unconditionally unlocks the lock by zeroing it.
42 returns true if it took the lock, false if the lock was already held.