]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3p/pthread_spin_init.3p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3p / pthread_spin_init.3p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "PTHREAD_SPIN_DESTROY" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" pthread_spin_destroy
4 .SH NAME
5 pthread_spin_destroy, pthread_spin_init \- destroy or initialize a
6 spin lock object (\fBADVANCED REALTIME
7 THREADS\fP)
8 .SH SYNOPSIS
9 .LP
10 \fB#include <pthread.h>
11 .br
12 .sp
13 int pthread_spin_destroy(pthread_spinlock_t *\fP\fIlock\fP\fB);
14 .br
15 int pthread_spin_init(pthread_spinlock_t *\fP\fIlock\fP\fB, int\fP
16 \fIpshared\fP\fB); \fP
17 \fB
18 .br
19 \fP
20 .SH DESCRIPTION
21 .LP
22 The \fIpthread_spin_destroy\fP() function shall destroy the spin lock
23 referenced by \fIlock\fP and release any resources used
24 by the lock. The effect of subsequent use of the lock is undefined
25 until the lock is reinitialized by another call to
26 \fIpthread_spin_init\fP(). The results are undefined if \fIpthread_spin_destroy\fP()
27 is called when a thread holds the lock, or
28 if this function is called with an uninitialized thread spin lock.
29 .LP
30 The \fIpthread_spin_init\fP() function shall allocate any resources
31 required to use the spin lock referenced by \fIlock\fP and
32 initialize the lock to an unlocked state.
33 .LP
34 If the Thread Process-Shared Synchronization option is supported and
35 the value of \fIpshared\fP is PTHREAD_PROCESS_SHARED, the
36 implementation shall permit the spin lock to be operated upon by any
37 thread that has access to the memory where the spin lock is
38 allocated, even if it is allocated in memory that is shared by multiple
39 processes.
40 .LP
41 If the Thread Process-Shared Synchronization option is supported and
42 the value of \fIpshared\fP is PTHREAD_PROCESS_PRIVATE,
43 or if the option is not supported, the spin lock shall only be
44 operated upon by threads created within the same process as the thread
45 that initialized the spin lock. If threads of differing
46 processes attempt to operate on such a spin lock, the behavior is
47 undefined.
48 .LP
49 The results are undefined if \fIpthread_spin_init\fP() is called specifying
50 an already initialized spin lock. The results are
51 undefined if a spin lock is used without first being initialized.
52 .LP
53 If the \fIpthread_spin_init\fP() function fails, the lock is not initialized
54 and the contents of \fIlock\fP are undefined.
55 .LP
56 Only the object referenced by \fIlock\fP may be used for performing
57 synchronization.
58 .LP
59 The result of referring to copies of that object in calls to \fIpthread_spin_destroy\fP(),
60 \fIpthread_spin_lock\fP(), \fIpthread_spin_trylock\fP(), or \fIpthread_spin_unlock\fP()
61 is undefined.
62 .SH RETURN VALUE
63 .LP
64 Upon successful completion, these functions shall return zero; otherwise,
65 an error number shall be returned to indicate the
66 error.
67 .SH ERRORS
68 .LP
69 These functions may fail if:
70 .TP 7
71 .B EBUSY
72 The implementation has detected an attempt to initialize or destroy
73 a spin lock while it is in use (for example, while being
74 used in a \fIpthread_spin_lock\fP() call) by another thread.
75 .TP 7
76 .B EINVAL
77 The value specified by \fIlock\fP is invalid.
78 .sp
79 .LP
80 The \fIpthread_spin_init\fP() function shall fail if:
81 .TP 7
82 .B EAGAIN
83 The system lacks the necessary resources to initialize another spin
84 lock.
85 .TP 7
86 .B ENOMEM
87 Insufficient memory exists to initialize the lock.
88 .sp
89 .LP
90 These functions shall not return an error code of [EINTR].
91 .LP
92 \fIThe following sections are informative.\fP
93 .SH EXAMPLES
94 .LP
95 None.
96 .SH APPLICATION USAGE
97 .LP
98 The \fIpthread_spin_destroy\fP() and \fIpthread_spin_init\fP() functions
99 are part of the Spin Locks option and need not be
100 provided on all implementations.
101 .SH RATIONALE
102 .LP
103 None.
104 .SH FUTURE DIRECTIONS
105 .LP
106 None.
107 .SH SEE ALSO
108 .LP
109 \fIpthread_spin_lock\fP() , \fIpthread_spin_unlock\fP() , the Base
110 Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<pthread.h>\fP
111 .SH COPYRIGHT
112 Portions of this text are reprinted and reproduced in electronic form
113 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
114 -- Portable Operating System Interface (POSIX), The Open Group Base
115 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
116 Electrical and Electronics Engineers, Inc and The Open Group. In the
117 event of any discrepancy between this version and the original IEEE and
118 The Open Group Standard, the original IEEE and The Open Group Standard
119 is the referee document. The original Standard can be obtained online at
120 http://www.opengroup.org/unix/online.html .