Initialize a thread spinlock
#include <pthread.h> int pthread_spin_init( pthread_spinlock_t * spinner, int pshared );
- A pointer to the pthread_spinlock_t object that you want to initialize.
- The value that you want to use for the process-shared attribute of the
The possible values are:
- PTHREAD_PROCESS_SHARED — the spinlock may be operated on by any thread that has access to the memory where the spinlock is allocated, even if it's allocated in memory that's shared by multiple processes.
- PTHREAD_PROCESS_PRIVATE — the spinlock can be operated on only by threads created within the same process as the thread that initialized the spinlock. If threads of differing processes attempt to operate on such a spinlock, the behavior is undefined.
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.
- The system doesn't have the resources required to initialize a new spinlock.
- The process spinlock, spinner, is in use by another thread and can't be initialized.
- Invalid pthread_spinlock_t object spinner.
- The system doesn't have enough free memory to create the new spinlock.
Last modified: 2013-12-23