pthread_spin_destroy (3)
NAME
pthread_spin_init, pthread_spin_destroy - initialize or destroy a spin lockSYNOPSIS
#include <pthread.h>
int pthread_spin_init(pthread_spinlock_t *lock int pshared); int pthread_spin_destroy(pthread_spinlock_t *lock);Compile and link with -pthread.
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
pthread_spin_init(), pthread_spin_destroy():
_POSIX_C_SOURCE >= 200112L
DESCRIPTION
General note: Most programs should use mutexes instead of spin locks. Spin locks are primarily useful in conjunction with real-time scheduling policies. See NOTES. The pthread_spin_init() function allocates any resources required for the use of the spin lock referred to by lock and initializes the lock to be in the unlocked state. The pshared argument must have one of the following values:- PTHREAD_PROCESS_PRIVATE
- The spin lock is to be operated on only by threads in the same process as the thread that calls pthread_spin_init(). (Attempting to share the spin lock between processes results in undefined behavior.)
- PTHREAD_PROCESS_SHARED
- The spin lock may be operated on by any thread in any process that has access to the memory containing the lock (i.e., the lock may be in a shared memory object that is shared among multiple processes).
RETURN VALUE
On success, there functions return zero. On failure, they return an error number. In the event that pthread_spin_init() fails, the lock is not initialized.ERRORS
pthread_spin_init() may fail with the following errors:- EAGAIN
- The system has insufficient resources to initialize a new spin lock.
- ENOMEM
- Insufficient memory to initialize the spin lock.