.nf
.B #include <pthread.h>
.PP
-.BI "int pthread_spin_init(pthread_spinlock_t *" clock " int " pshared ");"
-.BI "int pthread_spin_destroy(pthread_spinlock_t *" clock ");"
+.BI "int pthread_spin_init(pthread_spinlock_t *" lock ", int " pshared ");"
+.BI "int pthread_spin_destroy(pthread_spinlock_t *" lock ");"
.fi
.PP
Compile and link with \fI\-pthread\fP.
.RE
.ad
.SH DESCRIPTION
+.IR "General note" :
+Most programs should use mutexes
+instead of spin locks.
+Spin locks are primarily useful in conjunction with real-time
+scheduling policies.
+See NOTES.
+.PP
The
.BR pthread_spin_init ()
function allocates any resources required for the use of
.B PTHREAD_PROCESS_SHARED
The spin lock may be operated on by any thread in any process that
has access to the memory containing the lock
-(i.e.., the lock may be in a shared memory object that is
+(i.e., the lock may be in a shared memory object that is
shared among multiple processes).
.PP
Calling
once more initializing it with
.BR pthread_spin_init ()
results in undefined behavior.
+.PP
+The result of performing operations such as
+.BR pthread_spin_lock (3),
+.BR pthread_spin_unlock (3),
+and
+.BR pthread_spin_destroy (3)
+on
+.I copies
+of the object referred to by
+.I lock
+is undefined.
.SH RETURN VALUE
On success, there functions return zero.
On failure, they return an error number.
then other threads will waste time spinning on the lock
until the lock holder is once more rescheduled and releases the lock.
.PP
-.BR Warning :
-if threads create a deadlock situation while employing spin locks,
+If threads create a deadlock situation while employing spin locks,
those threads will spin forever consuming CPU time.
+.PP
+User-space spin locks are
+.I not
+applicable as a general locking solution.
+They are, by definition,
+prone to priority inversion and unbounded spin times.
+A programmer using spin locks must be exceptionally careful not
+only in the code, but also in terms of system configuration,
+thread placement, and priority assignment.
+.\" FIXME . When PTHREAD_MUTEX_ADAPTIVE_NP is one day document
+.\" make reference to it here
.SH SEE ALSO
.ad l
.nh
+.BR pthread_mutex_init (3),
+.BR pthread_mutex_lock (3),
.BR pthread_spin_lock (3),
.BR pthread_spin_unlock (3),
.BR pthreads (7)