- is a mutual exclusion device that can have only two values: "locked" and "unlocked."
- is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin")
while repeatedly checking if the lock is available.
Since the thread remains active but is not performing a useful task,
the use of such a lock is a kind of busy waiting.
spin — вращение
These locks allow any number of readers into a critical section simultaneously,
but writers must have exclusive access.
#include <pthread.h>
int pthread_spin_lock(pthread_spinlock_t *lock);
int pthread_spin_trylock(pthread_spinlock_t *lock);
<linux/spinlock.h>
// Once you call spin_lock, you will spin until the lock becomes available.
void spin_lock(spinlock_t *lock);
// To release a lock that you have obtained, pass it to:
void spin_unlock(spinlock_t *lock);