PTHREAD_SPIN_LOCK(3)

NAME
pthread_spin_lock, pthread_spin_trylock - acquire a spin lock

LIBRARY
libpthread

SYNOPSIS
#include <pthread.h>
int
pthread_spin_lock(pthread_spinlock_t *lock);
int
pthread_spin_trylock(pthread_spinlock_t *lock);

DESCRIPTION
The pthread_spin_lock() function acquires a spin lock on lock provided that lock is not presently held. If the lock cannot be immediately acquired, the calling thread repeatedly retries until it can acquire the lock.

The pthread_spin_trylock() function performs the same action, but does not block if the lock cannot be immediately obtained (i.e., the lock is held).

RETURN VALUES
If successful, the pthread_spin_lock() and pthread_spin_trylock() functions will return zero. Otherwise an error number will be returned to indicate the error.

ERRORS
The pthread_spin_trylock() function shall fail if:

[EBUSY]
    The lock could not be acquired because a writer holds the lock or was blocked on it.

The pthread_spin_lock() function may fail if:

[EDEADLK]
    The current thread already owns lock for writing.

The pthread_spin_lock() and pthread_spin_trylock() functions may fail if:

[EINVAL]
    The value specified by lock is invalid.

SEE ALSO
pthread_spin_destroy(3), pthread_spin_init(3), pthread_spin_unlock(3)

STANDARDS
pthread_spin_lock() and pthread_spin_trylock() conform to p1003.1-2001.