1PTHREAD_SPIN_DESTROY(P) POSIX Programmer's Manual PTHREAD_SPIN_DESTROY(P)
2
3
4
6 pthread_spin_destroy, pthread_spin_init - destroy or initialize a spin
7 lock object (ADVANCED REALTIME THREADS)
8
10 #include <pthread.h>
11
12 int pthread_spin_destroy(pthread_spinlock_t *lock);
13 int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
14
15
17 The pthread_spin_destroy() function shall destroy the spin lock refer‐
18 enced by lock and release any resources used by the lock. The effect of
19 subsequent use of the lock is undefined until the lock is reinitialized
20 by another call to pthread_spin_init(). The results are undefined if
21 pthread_spin_destroy() is called when a thread holds the lock, or if
22 this function is called with an uninitialized thread spin lock.
23
24 The pthread_spin_init() function shall allocate any resources required
25 to use the spin lock referenced by lock and initialize the lock to an
26 unlocked state.
27
28 If the Thread Process-Shared Synchronization option is supported and
29 the value of pshared is PTHREAD_PROCESS_SHARED, the implementation
30 shall permit the spin lock to be operated upon by any thread that has
31 access to the memory where the spin lock is allocated, even if it is
32 allocated in memory that is shared by multiple processes.
33
34 If the Thread Process-Shared Synchronization option is supported and
35 the value of pshared is PTHREAD_PROCESS_PRIVATE, or if the option is
36 not supported, the spin lock shall only be operated upon by threads
37 created within the same process as the thread that initialized the spin
38 lock. If threads of differing processes attempt to operate on such a
39 spin lock, the behavior is undefined.
40
41 The results are undefined if pthread_spin_init() is called specifying
42 an already initialized spin lock. The results are undefined if a spin
43 lock is used without first being initialized.
44
45 If the pthread_spin_init() function fails, the lock is not initialized
46 and the contents of lock are undefined.
47
48 Only the object referenced by lock may be used for performing synchro‐
49 nization.
50
51 The result of referring to copies of that object in calls to
52 pthread_spin_destroy(), pthread_spin_lock(), pthread_spin_trylock(), or
53 pthread_spin_unlock() is undefined.
54
56 Upon successful completion, these functions shall return zero; other‐
57 wise, an error number shall be returned to indicate the error.
58
60 These functions may fail if:
61
62 EBUSY The implementation has detected an attempt to initialize or
63 destroy a spin lock while it is in use (for example, while being
64 used in a pthread_spin_lock() call) by another thread.
65
66 EINVAL The value specified by lock is invalid.
67
68
69 The pthread_spin_init() function shall fail if:
70
71 EAGAIN The system lacks the necessary resources to initialize another
72 spin lock.
73
74 ENOMEM Insufficient memory exists to initialize the lock.
75
76
77 These functions shall not return an error code of [EINTR].
78
79 The following sections are informative.
80
82 None.
83
85 The pthread_spin_destroy() and pthread_spin_init() functions are part
86 of the Spin Locks option and need not be provided on all implementa‐
87 tions.
88
90 None.
91
93 None.
94
96 pthread_spin_lock() , pthread_spin_unlock() , the Base Definitions vol‐
97 ume of IEEE Std 1003.1-2001, <pthread.h>
98
100 Portions of this text are reprinted and reproduced in electronic form
101 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
102 -- Portable Operating System Interface (POSIX), The Open Group Base
103 Specifications Issue 6, Copyright (C) 2001-2003 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
111
112IEEE/The Open Group 2003 PTHREAD_SPIN_DESTROY(P)