~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to win32/3rdparty/pthreads/manual/pthread_spin_init.html

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
Import upstream version 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
 
<HTML>
3
 
<HEAD>
4
 
        <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
5
 
        <TITLE>&quot;PTHREAD_SPIN_DESTROY&quot;(P) manual page</TITLE>
6
 
        <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3  (Linux)">
7
 
        <META NAME="CREATED" CONTENT="20050505;12074100">
8
 
        <META NAME="CHANGED" CONTENT="20050505;19014200">
9
 
        <!-- manual page source format generated by PolyglotMan v3.2, -->
10
 
        <!-- available at http://polyglotman.sourceforge.net/ -->
11
 
</HEAD>
12
 
<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
13
 
<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
14
 
<P><A HREF="index.html">Reference Index</A></P>
15
 
<P><A HREF="#toc">Table of Contents</A></P>
16
 
<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
17
 
<P>pthread_spin_destroy, pthread_spin_init - destroy or initialize a
18
 
spin lock object (<B>ADVANCED REALTIME THREADS</B>) 
19
 
</P>
20
 
<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
21
 
<P><B>#include &lt;pthread.h&gt; </B>
22
 
</P>
23
 
<P><B>pthread_spinlock_t</B> <I>lock</I> <B>=
24
 
PTHREAD_SPINLOCK_INITIALIZER;</B></P>
25
 
<P><B>int pthread_spin_destroy(pthread_spinlock_t *</B><I>lock</I><B>);
26
 
<BR>int pthread_spin_init(pthread_spinlock_t *</B><I>lock</I><B>, int</B>
27
 
<I>pshared</I><B>); </B>
28
 
</P>
29
 
<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
30
 
<P>The <B>pthread_spin_destroy</B> function shall destroy the spin
31
 
lock referenced by <I>lock</I> and release any resources used by the
32
 
lock. The effect of subsequent use of the lock is undefined until the
33
 
lock is reinitialized by another call to <B>pthread_spin_init</B> .
34
 
The results are undefined if <B>pthread_spin_destroy</B> is called
35
 
when a thread holds the lock, or if this function is called with an
36
 
uninitialized thread spin lock. 
37
 
</P>
38
 
<P>The <B>pthread_spin_init</B> function shall allocate any resources
39
 
required to use the spin lock referenced by <I>lock</I> and
40
 
initialize the lock to an unlocked state. 
41
 
</P>
42
 
<P><B>Pthreads-w32</B> supports single and multiple processor systems
43
 
as well as process CPU affinity masking by checking the mask when the
44
 
spin lock is initialized. If the process is using only a single
45
 
processor at the time <B>pthread_spin_init</B> is called then the
46
 
spin lock is initialized as a PTHREAD_MUTEX_NORMAL mutex object. A
47
 
thread that calls <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock(3)</B></A>
48
 
will block rather than spin in this case. If the process CPU affinity
49
 
mask is altered after the spin lock has been initialised, the spin
50
 
lock is not modified, and may no longer be optimal for the number of
51
 
CPUs available.</P>
52
 
<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_PROCESS_SHARED</B> in
53
 
pthread.h as -1 to indicate that these routines do not support the
54
 
<B>PTHREAD_PROCESS_SHARED</B> attribute. <B>pthread_spin_init</B>
55
 
will return the error <B>ENOTSUP</B> if the value of <I>pshared</I>
56
 
is not <B>PTHREAD_PROCESS_PRIVATE</B>.</P>
57
 
<P>The results are undefined if <B>pthread_spin_init</B> is called
58
 
specifying an already initialized spin lock. The results are
59
 
undefined if a spin lock is used without first being initialized. 
60
 
</P>
61
 
<P>If the <B>pthread_spin_init</B> function fails, the lock is not
62
 
initialized and the contents of <I>lock</I> are undefined. 
63
 
</P>
64
 
<P>Only the object referenced by <I>lock</I> may be used for
65
 
performing synchronization. 
66
 
</P>
67
 
<P>The result of referring to copies of that object in calls to
68
 
<B>pthread_spin_destroy</B> , <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A>
69
 
, <A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B>(3)</A>,
70
 
or <A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B>(3)</A>
71
 
is undefined. 
72
 
</P>
73
 
<P><B>Pthreads-w32</B> supports statically initialized spin locks
74
 
using <B>PTHREAD_SPINLOCK_INITIALIZER</B>. An application should
75
 
still call <B>pthread_spin_destroy</B> at some point to ensure that
76
 
any resources consumed by the spin lock are released.</P>
77
 
<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
78
 
<P>Upon successful completion, these functions shall return zero;
79
 
otherwise, an error number shall be returned to indicate the error. 
80
 
</P>
81
 
<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
82
 
<P>These functions may fail if: 
83
 
</P>
84
 
<DL>
85
 
        <DT><B>EBUSY</B> 
86
 
        </DT><DD>
87
 
        The implementation has detected an attempt to initialize or destroy
88
 
        a spin lock while it is in use (for example, while being used in a
89
 
        <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A>
90
 
        call) by another thread. 
91
 
        </DD><DT>
92
 
        <B>EINVAL</B> 
93
 
        </DT><DD STYLE="margin-bottom: 0.5cm">
94
 
        The value specified by <I>lock</I> is invalid. 
95
 
        </DD></DL>
96
 
<P>
97
 
The <B>pthread_spin_init</B> function shall fail if: 
98
 
</P>
99
 
<DL>
100
 
        <DT><B>ENOTSUP</B> 
101
 
        </DT><DD>
102
 
        The value of <I>pshared</I> is not <B>PTHREAD_PROCESS_PRIVATE</B>.</DD><DT>
103
 
        <B>ENOMEM</B> 
104
 
        </DT><DD STYLE="margin-bottom: 0.5cm">
105
 
        Insufficient memory exists to initialize the lock. 
106
 
        </DD></DL>
107
 
<P>
108
 
These functions shall not return an error code of [EINTR]. 
109
 
</P>
110
 
<P><I>The following sections are informative.</I> 
111
 
</P>
112
 
<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2>
113
 
<P>None. 
114
 
</P>
115
 
<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2>
116
 
<P>The <B>pthread_spin_destroy</B> and <B>pthread_spin_init</B>
117
 
functions are part of the Spin Locks option and need not be provided
118
 
on all implementations. 
119
 
</P>
120
 
<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2>
121
 
<P>None. 
122
 
</P>
123
 
<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2>
124
 
<P>None. 
125
 
</P>
126
 
<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2>
127
 
<P><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A> <B>,</B>
128
 
<A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B>(3)</A>
129
 
<B>,</B> the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001,
130
 
<I>&lt;pthread.h&gt;</I> 
131
 
</P>
132
 
<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2>
133
 
<P>Portions of this text are reprinted and reproduced in electronic
134
 
form from IEEE Std 1003.1, 2003 Edition, Standard for Information
135
 
Technology -- Portable Operating System Interface (POSIX), The Open
136
 
Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the
137
 
Institute of Electrical and Electronics Engineers, Inc and The Open
138
 
Group. In the event of any discrepancy between this version and the
139
 
original IEEE and The Open Group Standard, the original IEEE and The
140
 
Open Group Standard is the referee document. The original Standard
141
 
can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A>
142
 
143
 
</P>
144
 
<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
145
 
<HR>
146
 
<P><A NAME="toc"></A><B>Table of Contents</B></P>
147
 
<UL>
148
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
149
 
                </P>
150
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
151
 
                </P>
152
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
153
 
                </P>
154
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
155
 
        Value</A> 
156
 
        </P>
157
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
158
 
                </P>
159
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A>
160
 
                </P>
161
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application
162
 
        Usage</A> 
163
 
        </P>
164
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A>
165
 
                </P>
166
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future
167
 
        Directions</A> 
168
 
        </P>
169
 
        <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See
170
 
        Also</A> 
171
 
        </P>
172
 
        <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> 
173
 
        </P>
174
 
</UL>
175
 
</BODY>
176
 
</HTML>