1PTHREAD_SPIN_DESTROY(3P) POSIX Programmer's Manual PTHREAD_SPIN_DESTROY(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_destroy, pthread_spin_init — destroy or initialize a spin
13 lock object
14
16 #include <pthread.h>
17
18 int pthread_spin_destroy(pthread_spinlock_t *lock);
19 int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
20
22 The pthread_spin_destroy() function shall destroy the spin lock refer‐
23 enced by lock and release any resources used by the lock. The effect of
24 subsequent use of the lock is undefined until the lock is reinitialized
25 by another call to pthread_spin_init(). The results are undefined if
26 pthread_spin_destroy() is called when a thread holds the lock, or if
27 this function is called with an uninitialized thread spin lock.
28
29 The pthread_spin_init() function shall allocate any resources required
30 to use the spin lock referenced by lock and initialize the lock to an
31 unlocked state.
32
33 If the Thread Process-Shared Synchronization option is supported and
34 the value of pshared is PTHREAD_PROCESS_SHARED, the implementation
35 shall permit the spin lock to be operated upon by any thread that has
36 access to the memory where the spin lock is allocated, even if it is
37 allocated in memory that is shared by multiple processes.
38
39 See Section 2.9.9, Synchronization Object Copies and Alternative Map‐
40 pings for further requirements.
41
42 The results are undefined if pthread_spin_init() is called specifying
43 an already initialized spin lock. The results are undefined if a spin
44 lock is used without first being initialized.
45
46 If the pthread_spin_init() function fails, the lock is not initialized
47 and the contents of lock are undefined.
48
49 Only the object referenced by lock may be used for performing synchro‐
50 nization.
51
52 The result of referring to copies of that object in calls to
53 pthread_spin_destroy(), pthread_spin_lock(), pthread_spin_trylock(), or
54 pthread_spin_unlock() is undefined.
55
57 Upon successful completion, these functions shall return zero; other‐
58 wise, an error number shall be returned to indicate the error.
59
61 The pthread_spin_init() function shall fail if:
62
63 EAGAIN The system lacks the necessary resources to initialize another
64 spin lock.
65
66 ENOMEM Insufficient memory exists to initialize the lock.
67
68 These functions shall not return an error code of [EINTR].
69
70 The following sections are informative.
71
73 None.
74
76 None.
77
79 If an implementation detects that the value specified by the lock argu‐
80 ment to pthread_spin_destroy() does not refer to an initialized spin
81 lock object, it is recommended that the function should fail and report
82 an [EINVAL] error.
83
84 If an implementation detects that the value specified by the lock argu‐
85 ment to pthread_spin_destroy() or pthread_spin_init() refers to a
86 locked spin lock object, or detects that the value specified by the
87 lock argument to pthread_spin_init() refers to an already initialized
88 spin lock object, it is recommended that the function should fail and
89 report an [EBUSY] error.
90
92 None.
93
95 pthread_spin_lock(), pthread_spin_unlock()
96
97 The Base Definitions volume of POSIX.1‐2017, <pthread.h>
98
100 Portions of this text are reprinted and reproduced in electronic form
101 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
102 table Operating System Interface (POSIX), The Open Group Base Specifi‐
103 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
104 Electrical and Electronics Engineers, Inc and The Open Group. In the
105 event of any discrepancy between this version and the original IEEE and
106 The Open Group Standard, the original IEEE and The Open Group Standard
107 is the referee document. The original Standard can be obtained online
108 at http://www.opengroup.org/unix/online.html .
109
110 Any typographical or formatting errors that appear in this page are
111 most likely to have been introduced during the conversion of the source
112 files to man page format. To report such errors, see https://www.ker‐
113 nel.org/doc/man-pages/reporting_bugs.html .
114
115
116
117IEEE/The Open Group 2017 PTHREAD_SPIN_DESTROY(3P)