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 (ADVANCED REALTIME THREADS)
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
21
23 The pthread_spin_destroy() function shall destroy the spin lock refer‐
24 enced by lock and release any resources used by the lock. The effect of
25 subsequent use of the lock is undefined until the lock is reinitialized
26 by another call to pthread_spin_init(). The results are undefined if
27 pthread_spin_destroy() is called when a thread holds the lock, or if
28 this function is called with an uninitialized thread spin lock.
29
30 The pthread_spin_init() function shall allocate any resources required
31 to use the spin lock referenced by lock and initialize the lock to an
32 unlocked state.
33
34 If the Thread Process-Shared Synchronization option is supported and
35 the value of pshared is PTHREAD_PROCESS_SHARED, the implementation
36 shall permit the spin lock to be operated upon by any thread that has
37 access to the memory where the spin lock is allocated, even if it is
38 allocated in memory that is shared by multiple processes.
39
40 If the Thread Process-Shared Synchronization option is supported and
41 the value of pshared is PTHREAD_PROCESS_PRIVATE, or if the option is
42 not supported, the spin lock shall only be operated upon by threads
43 created within the same process as the thread that initialized the spin
44 lock. If threads of differing processes attempt to operate on such a
45 spin lock, the behavior is undefined.
46
47 The results are undefined if pthread_spin_init() is called specifying
48 an already initialized spin lock. The results are undefined if a spin
49 lock is used without first being initialized.
50
51 If the pthread_spin_init() function fails, the lock is not initialized
52 and the contents of lock are undefined.
53
54 Only the object referenced by lock may be used for performing synchro‐
55 nization.
56
57 The result of referring to copies of that object in calls to
58 pthread_spin_destroy(), pthread_spin_lock(), pthread_spin_trylock(), or
59 pthread_spin_unlock() is undefined.
60
62 Upon successful completion, these functions shall return zero; other‐
63 wise, an error number shall be returned to indicate the error.
64
66 These functions may fail if:
67
68 EBUSY The implementation has detected an attempt to initialize or
69 destroy a spin lock while it is in use (for example, while being
70 used in a pthread_spin_lock() call) by another thread.
71
72 EINVAL The value specified by lock is invalid.
73
74
75 The pthread_spin_init() function shall fail if:
76
77 EAGAIN The system lacks the necessary resources to initialize another
78 spin lock.
79
80 ENOMEM Insufficient memory exists to initialize the lock.
81
82
83 These functions shall not return an error code of [EINTR].
84
85 The following sections are informative.
86
88 None.
89
91 The pthread_spin_destroy() and pthread_spin_init() functions are part
92 of the Spin Locks option and need not be provided on all implementa‐
93 tions.
94
96 None.
97
99 None.
100
102 pthread_spin_lock(), pthread_spin_unlock(), the Base Definitions volume
103 of IEEE Std 1003.1-2001, <pthread.h>
104
106 Portions of this text are reprinted and reproduced in electronic form
107 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
108 -- Portable Operating System Interface (POSIX), The Open Group Base
109 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
110 Electrical and Electronics Engineers, Inc and The Open Group. In the
111 event of any discrepancy between this version and the original IEEE and
112 The Open Group Standard, the original IEEE and The Open Group Standard
113 is the referee document. The original Standard can be obtained online
114 at http://www.opengroup.org/unix/online.html .
115
116
117
118IEEE/The Open Group 2003 PTHREAD_SPIN_DESTROY(3P)