pthread_spin_destroy(3P)
pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy - pthread spinlocks
Showing IRIX 6.5.30 (default release). Added in IRIX 6.5.30.
NAME pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy - pthread spinlocks C SYNOPSIS #include <pthread.h> int pthread_spin_init(pthread_spinlock_t * lock, int pshared); int pthread_spin_lock(pthread_spinlock_t * lock); int pthread_spin_trylock(pthread_spinlock_t * lock); int pthread_spin_unlock(pthread_spinlock_t * lock); int pthread_spin_destroy(pthread_spinlock_t * lock); DESCRIPTION Spinlocks are fast locking primitives that are operated on entirely in user space. A thread attempting to lock a spinlock held by another thread will continually spin attempting to get the lock, until its current holder releases it. pthread_spin_init() will initialize the spinlock referenced by lock and set it to an unlocked state. pthread_spin_destroy() will destroy the spinlock referenced by lock. The results of using an uninitialized lock or one that has not been reinitialized after being destroyed are undefined. If pshared is set to PTHREAD_PROCESS_SHARED then any process which has access to the memory where the lock is placed will be able to use the lock. If pshared is set to PTHREAD_PROCESS_PRIVATE then only threads in the same process that initialized the lock should use it. The results of a different process using a PTHREAD_PROCESS_PRIVATE lock are undefined. pthread_spin_lock() will lock the spinlock referenced by lock. If the lock is unlocked then it will take the lock, otherwise it will spin and not return until the lock has become available and it has acquired it. pthread_spin_trylock() will acquire the lock referenced by lock if the lock is not held. It will otherwise return indicating failure. pthread_spin_unlock() will unlock the lock referenced by lock. DIAGNOSTICS On success these functions return zero; otherwise an error number is returned: pthread_spin_lock() can return the following errors: [EINVAL] The value specified by lock is not an initialized spinlock. [EDEADLK] The calling thread already holds the lock. pthread_spin_trylock() can return the following errors: [EINVAL] The value specified by lock is not an initialized spinlock. [EBUSY] A thread currently holds the lock. pthread_spin_unlock() can return the following errors: [EINVAL] The value specified by lock is not an initialized spinlock. [EPERM] The calling thread does not hold the lock. pthread_spin_destroy() can return the following errors: [EBUSY] It is detected that the spinlock is in use. [EINVAL] The value specified by lock is invalid. SEE ALSO pthreads(5)