int
pthread_spin_lock(
pthread_spinlock_t *lock
)
int
pthread_spin_trylock(
pthread_spinlock_t *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).
)
and
pthread_spin_trylock(
)
functions will return zero.
Otherwise an error number will be returned to indicate the error.
)
function shall fail if:
EBUSY
]
The
pthread_spin_lock()
function may fail if:
EDEADLK
]
lock
for writing.
The
pthread_spin_lock()
and
pthread_spin_trylock(
)
functions may fail if:
EINVAL
]
lock
is invalid.
)
and
pthread_spin_trylock(
)
conform to
IEEE Std 1003.1-2001 (``POSIX.1'') .
SCHED_FIFO
, SCHED_RR
)
should not use these interfaces.
Outside carefully controlled environments, priority inversion with spinlocks
can lead to system deadlock.
Mutexes are preferable in nearly every possible use case.