[OpenBSD]

Manual Page Search Parameters

PTHREAD_SPIN_INIT(3) Library Functions Manual PTHREAD_SPIN_INIT(3)

pthread_spin_init, pthread_spin_destroy
initialize and destroy a spinlock object

#include <pthread.h>
int
pthread_spin_init(pthread_spinlock_t *lock, int pshared);
int
pthread_spin_destroy(pthread_spinlock_t *lock);

The pthread_spin_init() function creates a new spinlock object, with sharing attributes specified by pshared.
The pthread_spin_destroy() function frees the resources allocated for the lock.

If successful, pthread_spin_init() and pthread_spin_destroy() return zero; otherwise an error number is returned to indicate the error.

pthread_spin_init() will fail if:
 
 
[]
The value specified by lock is invalid.
 
 
[]
The process cannot allocate enough memory to create another spinlock object.
 
 
[]
The shared attributes specified by pshared are not supported by the current implementation.
pthread_spin_destroy() will fail if:
 
 
[]
The value specified by lock is invalid.
 
 
[]
The lock is still in use.

pthread_spin_lock(3), pthread_spin_unlock(3)

pthread_spin_init() and pthread_spin_destroy() conform to IEEE Std 1003.1-2008 (“POSIX.1”).

Currently only PTHREAD_PROCESS_PRIVATE spinlocks are supported and the pshared attribute is always set that way. Any attempts to initialize it to a different value will trigger ENOTSUP.
June 5, 2013 OpenBSD-current