Skip to content

spinlock

include/sync/spinlock.h View source View on GitHub
struct spinlock {
    _Atomic uint8_t  state;
};
void spinlock_init(struct spinlock *lock);
bool spin_trylock_raw(struct spinlock *lock);
void spin_raw(struct spinlock *lock);
void spin_lock_raw(struct spinlock *lock);
void spin_unlock_raw(struct spinlock *lock);
void spin_unlock(struct spinlock *lock, enum irql old);
enum irql spin_lock(struct spinlock *lock);
enum irql spin_lock_irq_disable(struct spinlock *lock);
bool spin_trylock(struct spinlock *lock, enum irql *out);
bool spin_trylock_irq_disable(struct spinlock *lock, enum irql *out);
bool spinlock_held(struct spinlock *lock);
#define SPINLOCK_COOKIE_MAGIC 0xBEEB00
#define SPINLOCK_INIT \
    {.state = ATOMIC_VAR_INIT(0), \
     .acquired_high = false, \
     .initialized_magic = SPINLOCK_COOKIE_MAGIC}
#define SPINLOCK_INIT {ATOMIC_VAR_INIT(0)}
#define SPINLOCK_ASSERT_HELD(l) kassert(spinlock_held(l))