]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - doc/html/ref/posix-thread-management.html
Initial revision
[karo-tx-redboot.git] / doc / html / ref / posix-thread-management.html
1 <!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2 <!-- This material may be distributed only subject to the terms      -->
3 <!-- and conditions set forth in the Open Publication License, v1.0  -->
4 <!-- or later (the latest version is presently available at          -->
5 <!-- http://www.opencontent.org/openpub/).                           -->
6 <!-- Distribution of the work or derivative of the work in any       -->
7 <!-- standard (paper) book form is prohibited unless prior           -->
8 <!-- permission is obtained from the copyright holder.               -->
9 <HTML
10 ><HEAD
11 ><TITLE
12 >Thread Management [POSIX Section 16]</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
14 <META
15 NAME="GENERATOR"
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17 "><LINK
18 REL="HOME"
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
21 REL="UP"
22 TITLE="POSIX Standard Support"
23 HREF="posix-standard-support.html"><LINK
24 REL="PREVIOUS"
25 TITLE="Message Passing [POSIX Section 15]"
26 HREF="posix-message-passing.html"><LINK
27 REL="NEXT"
28 TITLE="Thread-Specific Data [POSIX Section 17]"
29 HREF="posix-thread-specific-data.html"></HEAD
30 ><BODY
31 CLASS="SECT1"
32 BGCOLOR="#FFFFFF"
33 TEXT="#000000"
34 LINK="#0000FF"
35 VLINK="#840084"
36 ALINK="#0000FF"
37 ><DIV
38 CLASS="NAVHEADER"
39 ><TABLE
40 SUMMARY="Header navigation table"
41 WIDTH="100%"
42 BORDER="0"
43 CELLPADDING="0"
44 CELLSPACING="0"
45 ><TR
46 ><TH
47 COLSPAN="3"
48 ALIGN="center"
49 >eCos Reference Manual</TH
50 ></TR
51 ><TR
52 ><TD
53 WIDTH="10%"
54 ALIGN="left"
55 VALIGN="bottom"
56 ><A
57 HREF="posix-message-passing.html"
58 ACCESSKEY="P"
59 >Prev</A
60 ></TD
61 ><TD
62 WIDTH="80%"
63 ALIGN="center"
64 VALIGN="bottom"
65 >Chapter 31. POSIX Standard Support</TD
66 ><TD
67 WIDTH="10%"
68 ALIGN="right"
69 VALIGN="bottom"
70 ><A
71 HREF="posix-thread-specific-data.html"
72 ACCESSKEY="N"
73 >Next</A
74 ></TD
75 ></TR
76 ></TABLE
77 ><HR
78 ALIGN="LEFT"
79 WIDTH="100%"></DIV
80 ><DIV
81 CLASS="SECT1"
82 ><H1
83 CLASS="SECT1"
84 ><A
85 NAME="POSIX-THREAD-MANAGEMENT">Thread Management &#0091;POSIX Section 16&#0093;</H1
86 ><DIV
87 CLASS="SECT2"
88 ><H2
89 CLASS="SECT2"
90 ><A
91 NAME="AEN13263">Functions Implemented</H2
92 ><TABLE
93 BORDER="5"
94 BGCOLOR="#E0E0F0"
95 WIDTH="70%"
96 ><TR
97 ><TD
98 ><PRE
99 CLASS="SCREEN"
100 >int pthread&#0095;attr&#0095;init(pthread&#0095;attr&#0095;t &#0042;attr); 
101 int pthread&#0095;attr&#0095;destroy(pthread&#0095;attr&#0095;t &#0042;attr); 
102 int pthread&#0095;attr&#0095;setdetachstate(pthread&#0095;attr&#0095;t &#0042;attr,
103                                 int detachstate); 
104 int pthread&#0095;attr&#0095;getdetachstate(const pthread&#0095;attr&#0095;t &#0042;attr,
105                                 int &#0042;detachstate); 
106 int pthread&#0095;attr&#0095;setstackaddr(pthread&#0095;attr&#0095;t &#0042;attr,
107                               void &#0042;stackaddr); 
108 int pthread&#0095;attr&#0095;getstackaddr(const pthread&#0095;attr&#0095;t &#0042;attr,
109                               void &#0042;&#0042;stackaddr); 
110 int pthread&#0095;attr&#0095;setstacksize(pthread&#0095;attr&#0095;t &#0042;attr,
111                               size&#0095;t stacksize); 
112 int pthread&#0095;attr&#0095;getstacksize(const pthread&#0095;attr&#0095;t &#0042;attr,
113                               size&#0095;t &#0042;stacksize); 
114 int pthread&#0095;create( pthread&#0095;t &#0042;thread,
115                     const pthread&#0095;attr&#0095;t &#0042;attr,
116                     void &#0042;(&#0042;start&#0095;routine)(void &#0042;),
117                     void &#0042;arg);
118 pthread&#0095;t pthread&#0095;self( void ); 
119 int pthread&#0095;equal(pthread&#0095;t thread1, pthread&#0095;t thread2); 
120 void pthread&#0095;exit(void &#0042;retval); 
121 int pthread&#0095;join(pthread&#0095;t thread, void &#0042;&#0042;thread&#0095;return); 
122 int pthread&#0095;detach(pthread&#0095;t thread); 
123 int pthread&#0095;once(pthread&#0095;once&#0095;t &#0042;once&#0095;control,
124                  void (&#0042;init&#0095;routine)(void));</PRE
125 ></TD
126 ></TR
127 ></TABLE
128 ></DIV
129 ><DIV
130 CLASS="SECT2"
131 ><H2
132 CLASS="SECT2"
133 ><A
134 NAME="AEN13266">Functions Omitted</H2
135 ><P
136 >&lt;none&gt;</P
137 ></DIV
138 ><DIV
139 CLASS="SECT2"
140 ><H2
141 CLASS="SECT2"
142 ><A
143 NAME="AEN13269">Notes</H2
144 ><P
145 ></P
146 ><UL
147 ><LI
148 ><P
149 >    The presence of thread support as a whole is controlled by the the
150     CYGPKG_POSIX_PTHREAD configuration option. Note that disabling
151     this will also disable many other features of the POSIX package,
152     since these are intimately bound up with the thread mechanism.
153     </P
154 ></LI
155 ><LI
156 ><P
157 >    The default (non-scheduling) thread attributes are:
158     </P
159 ><TABLE
160 BORDER="5"
161 BGCOLOR="#E0E0F0"
162 WIDTH="70%"
163 ><TR
164 ><TD
165 ><PRE
166 CLASS="SCREEN"
167 >    detachstate            PTHREAD&#0095;CREATE&#0095;JOINABLE
168     stackaddr              unset
169     stacksize              unset
170     </PRE
171 ></TD
172 ></TR
173 ></TABLE
174 ></LI
175 ><LI
176 ><P
177 >      Dynamic thread stack allocation is only provided if there is an
178       implementation of
179       <SPAN
180 CLASS="emphasis"
181 ><I
182 CLASS="EMPHASIS"
183 >malloc()</I
184 ></SPAN
185 > configured (i.e. a package
186       implements the
187       CYGINT&#0095;MEMALLOC&#0095;MALLOC&#0095;ALLOCATORS
188       interface). If there is no malloc() available, then the thread
189       creator must supply a stack. If only a stack address is supplied
190       then the stack is assumed to be PTHREAD&#0095;STACK&#0095;MIN
191       bytes long. This size is seldom useful for any but the most
192       trivial of threads.  If a different sized stack is used, both
193       the stack address and stack size must be supplied.
194     </P
195 ></LI
196 ><LI
197 ><P
198 >      The value of PTHREAD&#0095;THREADS&#0095;MAX is supplied by
199       the CYGNUM&#0095;POSIX&#0095;PTHREAD&#0095;THREADS&#0095;MAX
200       option. This defines the maximum number of threads allowed. The
201       POSIX standard requires this value to be at least 64, and this
202       is the default value set.
203     </P
204 ></LI
205 ><LI
206 ><P
207 >    When the POSIX package is installed, the thread that calls 
208     <SPAN
209 CLASS="emphasis"
210 ><I
211 CLASS="EMPHASIS"
212 >main()</I
213 ></SPAN
214 > is initialized as a POSIX thread. The
215     priority of that thread is controlled by the
216     CYGNUM&#0095;POSIX&#0095;MAIN&#0095;DEFAULT&#0095;PRIORITY option.
217     </P
218 ></LI
219 ></UL
220 ></DIV
221 ></DIV
222 ><DIV
223 CLASS="NAVFOOTER"
224 ><HR
225 ALIGN="LEFT"
226 WIDTH="100%"><TABLE
227 SUMMARY="Footer navigation table"
228 WIDTH="100%"
229 BORDER="0"
230 CELLPADDING="0"
231 CELLSPACING="0"
232 ><TR
233 ><TD
234 WIDTH="33%"
235 ALIGN="left"
236 VALIGN="top"
237 ><A
238 HREF="posix-message-passing.html"
239 ACCESSKEY="P"
240 >Prev</A
241 ></TD
242 ><TD
243 WIDTH="34%"
244 ALIGN="center"
245 VALIGN="top"
246 ><A
247 HREF="ecos-ref.html"
248 ACCESSKEY="H"
249 >Home</A
250 ></TD
251 ><TD
252 WIDTH="33%"
253 ALIGN="right"
254 VALIGN="top"
255 ><A
256 HREF="posix-thread-specific-data.html"
257 ACCESSKEY="N"
258 >Next</A
259 ></TD
260 ></TR
261 ><TR
262 ><TD
263 WIDTH="33%"
264 ALIGN="left"
265 VALIGN="top"
266 >Message Passing &#0091;POSIX Section 15&#0093;</TD
267 ><TD
268 WIDTH="34%"
269 ALIGN="center"
270 VALIGN="top"
271 ><A
272 HREF="posix-standard-support.html"
273 ACCESSKEY="U"
274 >Up</A
275 ></TD
276 ><TD
277 WIDTH="33%"
278 ALIGN="right"
279 VALIGN="top"
280 >Thread-Specific Data &#0091;POSIX Section 17&#0093;</TD
281 ></TR
282 ></TABLE
283 ></DIV
284 ></BODY
285 ></HTML
286 >