Initialize a thread spinlock
#include <pthread.h>
int pthread_spin_init( pthread_spinlock_t * spinner,
int pshared );
![]() |
It's always safe, and typically faster, to assure that spinner is 32-bit aligned. |
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The pthread_spin_init() function allocates the resources required for the thread spinlock spinner, and initializes spinner to an unlocked state.
Any thread that can access the memory where spinner is allocated can operate on the spinlock.
Results are undefined if you call pthread_spin_init() on a spinner that's already initialized, or if you try to use a spinlock that hasn't been initialized.
Zero on success, or an error number to indicate the error.
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
pthread_spin_destroy(), pthread_spin_lock(), pthread_spin_trylock(), pthread_spin_unlock()