File: pthread_create.3.html

package info (click to toggle)
rtlinux 3.1pre3-2
  • links: PTS
  • area: non-free
  • in suites: sarge, woody
  • size: 4,892 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (264 lines) | stat: -rw-r--r-- 4,277 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<HTML
><HEAD
><TITLE
>pthread_create</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"></HEAD
><BODY
CLASS="REFENTRY"
><H1
><A
NAME="AEN1"
>pthread_create</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN5"
></A
><H2
>Name</H2
>pthread_create&nbsp;--&nbsp;create a thread</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN8"
></A
><H2
>Synopsis</H2
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SYNOPSIS"
>       #include &#60;rtl_sched.h&#62;

int <TT
CLASS="FUNCTION"
>pthread_create</TT
>(pthread_t <TT
CLASS="PARAMETER"
><I
>*thread</I
></TT
>, pthread_attr_t <TT
CLASS="PARAMETER"
><I
>*attr</I
></TT
>, void *<TT
CLASS="PARAMETER"
><I
>(*start_routine)(void *)</I
></TT
>, void <TT
CLASS="PARAMETER"
><I
>*arg</I
></TT
>);</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN15"
></A
><H2
>DESCRIPTION</H2
><P
>This function is an RTLinux version of standard POSIX threads function. 
<TT
CLASS="FUNCTION"
>pthread_create</TT
>  creates a realtime thread  that
will have attributes given by <TT
CLASS="PARAMETER"
><I
>attr</I
></TT
>, and that begins executing 
function <TT
CLASS="FUNCTION"
>start_routine</TT
>(<TT
CLASS="PARAMETER"
><I
>arg </I
></TT
>). If the attribute is NULL,
default attributes are used.
The thread attributes in RTLinux are extended to allow thread creation on specific
processors (<TT
CLASS="FUNCTION"
>pthread_attr_setcpu_np</TT
>), to enable FPU operations
in the created thread (<TT
CLASS="FUNCTION"
>pthread_attr_setfp_np</TT
>).</P
><P
>The standard thread attribute setting functions supported include
<TT
CLASS="FUNCTION"
>pthread_attr_setschedparam</TT
>,
<TT
CLASS="FUNCTION"
>pthread_attr_setdetachstate</TT
>,
<TT
CLASS="FUNCTION"
>pthread_attr_setstacksize</TT
>,
<TT
CLASS="FUNCTION"
>pthread_attr_setstackaddr</TT
>.
The last call is to allow users to allocate memory for thread stacks
-- so that threads can be
created in RT operating mode by making use of pre-allocated memory.
<TT
CLASS="FUNCTION"
>pthread_join</TT
> should be used to synchronize freeing of 
thread resources including memory. For example if a thread is created with
user allocated stack via <TT
CLASS="FUNCTION"
>pthread_attr_setstackaddr</TT
>, that
memory can only be safely reallocated after a <TT
CLASS="FUNCTION"
>pthread_join</TT
>.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN32"
></A
><H2
>RETURN VALUE</H2
><P
><TT
CLASS="FUNCTION"
>pthread_create</TT
> returns 0 on success and a non-zero error code on error.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN36"
></A
><H2
>ERRORS</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>[EAGAIN]</DT
><DD
><P
>Either not enough memory, or 
         PTHREAD_THREADS_MAX would be exceeded, or pthread_create is called
	from RT-thread context and preallocated stack use is not specified.</P
></DD
><DT
>[EINVAL]</DT
><DD
><P
>    Bad attributes.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN47"
></A
><H2
>AUTHOR</H2
><P
>Victor Yodaiken (<A
HREF="mailto:support@fsmlabs.com"
TARGET="_top"
>support@fsmlabs.com</A
>)</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN51"
></A
><H2
>NOTES</H2
><P
>In the absense of preallocated stack (via <TT
CLASS="FUNCTION"
>pthread_attr_setstackaddr</TT
>), the use of this function is restricted to the Linux
 <TT
CLASS="FUNCTION"
>init_module()</TT
> or <TT
CLASS="FUNCTION"
>cleanup_module()</TT
> context.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN57"
></A
><H2
>SEE ALSO</H2
><A
HREF="../susv2/xsh/pthread_create.html"
TARGET="_top"
>UNIX spec pthread_create(3)</A
>, <A
HREF="../susv2/xsh/pthread_attr_getstackaddr.html"
TARGET="_top"
>pthread_attr_setstackaddr(3)</A
>, <A
HREF="../susv2/xsh/pthread_attr_getstacksize.html"
TARGET="_top"
>pthread_attr_setstacksize(3)</A
>, <A
HREF="pthread_join.3.html"
TARGET="_top"
>pthread_join(3)</A
>, <A
HREF="pthread_make_periodic_np.3.html"
TARGET="_top"
>pthread_make_periodic_np(3)</A
>, <A
HREF="pthread_attr_setcpu_np.3.html"
TARGET="_top"
>pthread_attr_setcpu_np(3)</A
>, <A
HREF="pthread_attr_getcpu_np.3.html"
TARGET="_top"
>pthread_attr_getcpu_np(3)</A
>, <A
HREF="pthread_attr_setfp_np.3.html"
TARGET="_top"
>pthread_attr_setfp_np(3)</A
><P
>2001 FSMLabs Inc.</P
><P
>All rights reserved.</P
></DIV
></BODY
></HTML
>