Locks a spin lock object.
#include <pthread.h>
int pthread_spin_lock(pthread_spinlock_t *lock);
int pthread_spin_trylock(pthread_spinlock_t *lock);
The pthread_spin_lock subroutine locks the spin lock referenced by the lock parameter. The calling thread shall acquire the lock if it is not held by another thread. Otherwise, the thread spins (that is, does not return from the pthread_spin_lock call) until the lock becomes available. The results are undefined if the calling thread holds the lock at the time the call is made. The pthread_spin_trylock subroutine locks the spin lock referenced by the lock parameter if it is not held by any thread. Otherwise, the function fails.
The results are undefined if any of these subroutines is called with an uninitialized spin lock.
Upon successful completion, these functions return zero; otherwise, an error number is returned to indicate the error.
Item | Description |
---|---|
EINVAL | The value specified by the lock parameter does not refer to an initialized spin lock object. |
Item | Description |
---|---|
EDEADLK | The calling thread already holds the lock. |
Item | Description |
---|---|
EBUSY | A thread currently holds the lock. |