Spin locks. More...
Spin locks.
Definition in file pthread_spin.h.
#include <stdatomic.h>
Go to the source code of this file.
Data Structures | |
struct | pthread_spinlock_t |
A spinlock. More... | |
int | pthread_spin_init (pthread_spinlock_t *lock, int pshared) |
Initializes a spinlock. More... | |
int | pthread_spin_destroy (pthread_spinlock_t *lock) |
Destroys a spinlock. More... | |
int | pthread_spin_lock (pthread_spinlock_t *lock) |
Lock a spinlock. More... | |
int | pthread_spin_trylock (pthread_spinlock_t *lock) |
Tries to lock a spinlock, returns immediately if already locked. More... | |
int | pthread_spin_unlock (pthread_spinlock_t *lock) |
Releases a spinlock. More... | |
int pthread_spin_destroy | ( | pthread_spinlock_t * | lock | ) |
Destroys a spinlock.
Destroying a spinlock while a thread is waiting for it causes undefined behavior. This is a no-op.
[in,out] | lock | Datum to destroy. |
0
on success. EINVAL
if lock == NULL
. int pthread_spin_init | ( | pthread_spinlock_t * | lock, |
int | pshared | ||
) |
Initializes a spinlock.
A zeroed out datum is initialized.
[in,out] | lock | Datum to initialize. |
[in] | pshared | Unused. |
0
on success. EINVAL
if lock == NULL
. int pthread_spin_lock | ( | pthread_spinlock_t * | lock | ) |
Lock a spinlock.
[in,out] | lock | Lock to acquire. |
0
on success. EINVAL
if lock == NULL
. int pthread_spin_trylock | ( | pthread_spinlock_t * | lock | ) |
Tries to lock a spinlock, returns immediately if already locked.
[in,out] | lock | Lock to acquire. |
0
on success. EBUSY
if the lock was already locked. EINVAL
if lock == NULL
. int pthread_spin_unlock | ( | pthread_spinlock_t * | lock | ) |
Releases a spinlock.
[in,out] | lock | Lock to release |
0
on success. EPERM
if the lock was not locked. EINVAL
if lock == NULL
.