1PTHREAD_SPIN_LOCK(3P) POSIX Programmer's Manual PTHREAD_SPIN_LOCK(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 pthread_spin_lock, pthread_spin_trylock - lock a spin lock object
13 (ADVANCED REALTIME THREADS)
14
16 #include <pthread.h>
17
18 int pthread_spin_lock(pthread_spinlock_t *lock);
19 int pthread_spin_trylock(pthread_spinlock_t *lock);
20
21
23 The pthread_spin_lock() function shall lock the spin lock referenced by
24 lock. The calling thread shall acquire the lock if it is not held by
25 another thread. Otherwise, the thread shall spin (that is, shall not
26 return from the pthread_spin_lock() call) until the lock becomes avail‐
27 able. The results are undefined if the calling thread holds the lock
28 at the time the call is made. The pthread_spin_trylock() function shall
29 lock the spin lock referenced by lock if it is not held by any thread.
30 Otherwise, the function shall fail.
31
32 The results are undefined if any of these functions is called with an
33 uninitialized spin lock.
34
36 Upon successful completion, these functions shall return zero; other‐
37 wise, an error number shall be returned to indicate the error.
38
40 These functions may fail if:
41
42 EINVAL The value specified by lock does not refer to an initialized
43 spin lock object.
44
45
46 The pthread_spin_lock() function may fail if:
47
48 EDEADLK
49 The calling thread already holds the lock.
50
51
52 The pthread_spin_trylock() function shall fail if:
53
54 EBUSY A thread currently holds the lock.
55
56
57 These functions shall not return an error code of [EINTR].
58
59 The following sections are informative.
60
62 None.
63
65 Applications using this function may be subject to priority inversion,
66 as discussed in the Base Definitions volume of IEEE Std 1003.1-2001,
67 Section 3.285, Priority Inversion.
68
69 The pthread_spin_lock() and pthread_spin_trylock() functions are part
70 of the Spin Locks option and need not be provided on all implementa‐
71 tions.
72
74 None.
75
77 None.
78
80 pthread_spin_destroy(), pthread_spin_unlock(), the Base Definitions
81 volume of IEEE Std 1003.1-2001, <pthread.h>
82
84 Portions of this text are reprinted and reproduced in electronic form
85 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
86 -- Portable Operating System Interface (POSIX), The Open Group Base
87 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
88 Electrical and Electronics Engineers, Inc and The Open Group. In the
89 event of any discrepancy between this version and the original IEEE and
90 The Open Group Standard, the original IEEE and The Open Group Standard
91 is the referee document. The original Standard can be obtained online
92 at http://www.opengroup.org/unix/online.html .
93
94
95
96IEEE/The Open Group 2003 PTHREAD_SPIN_LOCK(3P)