1 .\" $NetBSD: pthread_attr.3,v 1.10 2009/04/11 16:51:39 wiz Exp $
3 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
27 .\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
28 .\" All rights reserved.
30 .\" Redistribution and use in source and binary forms, with or without
31 .\" modification, are permitted provided that the following conditions
33 .\" 1. Redistributions of source code must retain the above copyright
34 .\" notice(s), this list of conditions and the following disclaimer as
35 .\" the first lines of this file unmodified other than the possible
36 .\" addition of one or more copyright notices.
37 .\" 2. Redistributions in binary form must reproduce the above copyright
38 .\" notice(s), this list of conditions and the following disclaimer in
39 .\" the documentation and/or other materials provided with the
42 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
43 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
46 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
49 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
51 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
52 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 .\" $FreeBSD: src/lib/libpthread/man/pthread_attr.3,v 1.11 2002/09/16 19:29:28 mini Exp $
60 .Nm pthread_attr_init ,
61 .Nm pthread_attr_destroy ,
62 .Nm pthread_attr_setstacksize ,
63 .Nm pthread_attr_getstacksize ,
64 .Nm pthread_attr_setguardsize ,
65 .Nm pthread_attr_getguardsize ,
66 .Nm pthread_attr_setstackaddr ,
67 .Nm pthread_attr_getstackaddr ,
68 .Nm pthread_attr_setdetachstate ,
69 .Nm pthread_attr_getdetachstate ,
70 .Nm pthread_attr_setinheritsched ,
71 .Nm pthread_attr_getinheritsched ,
72 .Nm pthread_attr_setschedparam ,
73 .Nm pthread_attr_getschedparam
74 .Nm pthread_attr_setschedpolicy ,
75 .Nm pthread_attr_getschedpolicy ,
76 .Nm pthread_attr_setscope ,
77 .Nm pthread_attr_getscope
78 .Nd thread attribute operations
84 .Fn pthread_attr_init "pthread_attr_t *attr"
86 .Fn pthread_attr_destroy "pthread_attr_t *attr"
88 .Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize"
90 .Fn pthread_attr_getstacksize "const pthread_attr_t * restrict attr" "size_t * restrict stacksize"
92 .Fn pthread_attr_setguardsize "pthread_attr_t *attr" "size_t guardsize"
94 .Fn pthread_attr_getguardsize "const pthread_attr_t * restrict attr" "size_t * restrict guardsize"
96 .Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr"
98 .Fn pthread_attr_getstackaddr "const pthread_attr_t * restrict attr" "void ** restrict stackaddr"
100 .Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
102 .Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate"
104 .Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched"
106 .Fn pthread_attr_getinheritsched "const pthread_attr_t * restrict attr" "int * restrict inheritsched"
108 .Fn pthread_attr_setschedparam "pthread_attr_t * restrict attr" "const struct sched_param * restrict param"
110 .Fn pthread_attr_getschedparam "const pthread_attr_t * restrict attr" "struct sched_param * restrict param"
112 .Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy"
114 .Fn pthread_attr_getschedpolicy "const pthread_attr_t * restrict attr" "int * restrict policy"
116 .Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope"
118 .Fn pthread_attr_getscope "const pthread_attr_t * restrict attr" "int * restrict contentionscope"
120 Thread attributes are used to specify parameters to
122 One attribute object can be used in multiple calls to
124 with or without modifications between calls.
127 .Fn pthread_attr_init
130 with all the default thread attributes.
133 .Fn pthread_attr_destroy
138 .Fn pthread_attr_set*
139 functions set the attribute that corresponds to each function name.
142 .Fn pthread_attr_get*
143 functions copy the value of the attribute that corresponds to each function name
144 to the location pointed to by the second function parameter.
146 The attribute parameters for the
147 .Fn pthread_attr_setdetachstate
149 .Fn pthread_attr_getdetachstate
150 are mutually exclusive and must be one of:
151 .Bl -tag -width xxxxxxxx
152 .It Dv PTHREAD_CREATE_JOINABLE
153 The threads must explicitly be waited for using the
155 function once they exit for their status to be received and their resources
158 .It Dv PTHREAD_CREATE_DETACHED
159 The thread's resources will automatically be freed once the thread exits,
160 and the thread will not be joined.
163 If successful, these functions return 0.
164 Otherwise, an error number is returned to indicate the error.
166 .Fn pthread_attr_init
173 .Fn pthread_attr_destroy
177 The value specified by
182 .Fn pthread_attr_setstacksize
188 .Dv PTHREAD_STACK_MIN .
191 .Fn pthread_attr_setdetachstate
195 The value specified by
200 Fn pthread_attr_setinheritsched
208 .Fn pthread_attr_setschedparam
212 The value specified by
216 The value specified by
221 .Fn pthread_attr_setschedpolicy
228 Invalid or unsupported value for
232 .Fn pthread_attr_setscope
239 Invalid or unsupported value for
240 .Fa contentionscope .
243 .Xr pthread_create 3 ,
246 .Fn pthread_attr_init ,
247 .Fn pthread_attr_destroy ,
248 .Fn pthread_attr_setstacksize ,
249 .Fn pthread_attr_getstacksize ,
250 .Fn pthread_attr_setstackaddr ,
251 .Fn pthread_attr_getstackaddr ,
252 .Fn pthread_attr_setdetachstate ,
253 .Fn pthread_attr_getdetachstate ,
254 .Fn pthread_attr_setinheritsched ,
255 .Fn pthread_attr_getinheritsched ,
256 .Fn pthread_attr_setschedparam ,
257 .Fn pthread_attr_setschedparam ,
259 .Fn pthread_attr_getschedparam
260 .Fn pthread_attr_setschedpolicy ,
261 .Fn pthread_attr_getschedpolicy ,
262 .Fn pthread_attr_setscope ,
264 .Fn pthread_attr_getscope