| PTHREAD_SPIN_INIT(3) | Library Functions Manual | PTHREAD_SPIN_INIT(3) |
pthread_spin_init,
pthread_spin_destroy —
initialize and destroy a spinlock object
POSIX Threads Library (libpthread,
-lpthread)
#include <pthread.h>
int
pthread_spin_init(pthread_spinlock_t
*lock, int
pshared);
int
pthread_spin_destroy(pthread_spinlock_t
*lock);
The
pthread_spin_init()
function creates a new spinlock object, with sharing attributes specified by
pshared.
The
pthread_spin_destroy()
function frees the resources allocated for the
lock.
If successful, pthread_spin_init() and
pthread_spin_destroy() return zero; otherwise an
error number is returned to indicate the error.
pthread_spin_init() will fail if:
EINVAL]ENOMEM]ENOTSUP]pthread_spin_destroy() will fail if:
pthread_spin_init() and
pthread_spin_destroy() conform to
IEEE Std 1003.1-2008 (“POSIX.1”).
Currently only PTHREAD_PROCESS_PRIVATE
spinlocks are supported and the pshared attribute is always set that way.
Any attempts to initialize it to a different value will trigger
ENOTSUP.
| June 7, 2025 | Debian |