int
pthread_spin_init(
pthread_spinlock_t *lock
, int pshared
)
)
function is used to initialize a spinlock.
The
pshared
parameter is currently unused and all spinlocks exhibit the
PTHREAD_PROCESS_SHARED
property.
The results of calling
pthread_spin_init()
with an already initialized lock are undefined.
)
function will return zero.
Otherwise an error number will be returned to indicate the error.
)
function shall fail if:
ENOMEM
]
The
pthread_spin_init()
function may fail if:
EINVAL
]
lock
parameter was NULL or the
pshared
parameter was neither
PTHREAD_PROCESS_SHARED
nor
PTHREAD_PROCESS_PRIVATE
.
)
conforms 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.