SPINLOCK(9) Hyra Kernel Developer’s Manual SPINLOCK(9)
NAME
spinlock - generic spinlock for syncronization
SYNOPSIS
#include <sys/spinlock.h>
void
spinlock_acquire(struct spinlock *lock);
void
spinlock_release(struct spinlock *lock);
int
spinlock_usleep(struct spinlock *lock, size_t usec_max);
DESCRIPTION
The set of functions provide a simple spin-based locking mechanism to ensure mutual exclusion between threads.
The spinlock_acquire function is used to acquire a spinlock pointed to by lock. If the lock is unavailable (being held by another thread), it will wait until the lock owner releases it.
The spinlock_release function is used to release a spinlock pointed to by lock. This allows other threads to hold it.
The spinlock_usleep function attempts to acquire a spinlock pointed to by lock. If the lock is unavailable, it waits up to a maximum duration of usec_max microseconds. If the lock is still being held, it will return a non-zero value indicating a timeout. If the lock is successfully acquired, a value of 0 is returned.
AUTHORS
Ian Moffett <ian@osmora.org>
Hyra Dec 16 2024 Hyra