]> git.saurik.com Git - apple/libc.git/blame - pthreads/pthread_attr.3
Libc-498.1.1.tar.gz
[apple/libc.git] / pthreads / pthread_attr.3
CommitLineData
5b2abdfb
A
1.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice(s), this list of conditions and the following disclaimer as
9.\" the first lines of this file unmodified other than the possible
10.\" addition of one or more copyright notices.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice(s), this list of conditions and the following disclaimer in
13.\" the documentation and/or other materials provided with the
14.\" distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $FreeBSD: src/lib/libc_r/man/pthread_attr.3,v 1.4.2.5 2001/08/17 15:42:51 ru Exp $
29.Dd April 28, 2000
30.Dt PTHREAD_ATTR 3
31.Os
32.Sh NAME
5b2abdfb 33.Nm pthread_attr_destroy ,
224c7076
A
34.Nm pthread_attr_getdetachstate ,
35.Nm pthread_attr_getinheritsched ,
36.Nm pthread_attr_getschedparam ,
37.Nm pthread_attr_getschedpolicy ,
38.Nm pthread_attr_getscope ,
5b2abdfb 39.Nm pthread_attr_getstackaddr ,
224c7076
A
40.Nm pthread_attr_getstacksize ,
41.Nm pthread_attr_init ,
5b2abdfb 42.Nm pthread_attr_setdetachstate ,
5b2abdfb 43.Nm pthread_attr_setinheritsched ,
5b2abdfb 44.Nm pthread_attr_setschedparam ,
5b2abdfb 45.Nm pthread_attr_setschedpolicy ,
5b2abdfb 46.Nm pthread_attr_setscope ,
224c7076
A
47.Nm pthread_attr_setstackaddr ,
48.Nm pthread_attr_setstacksize
5b2abdfb
A
49.Nd thread attribute operations
50.Sh SYNOPSIS
51.Fd #include <pthread.h>
52.Ft int
224c7076
A
53.Fo pthread_attr_destroy
54.Fa "pthread_attr_t *attr"
55.Fc
5b2abdfb 56.Ft int
224c7076
A
57.Fo pthread_attr_getdetachstate
58.Fa "const pthread_attr_t *attr"
59.Fa "int *detachstate"
60.Fc
5b2abdfb 61.Ft int
224c7076
A
62.Fo pthread_attr_getinheritsched
63.Fa "const pthread_attr_t *restrict attr"
64.Fa "int *restrict inheritsched"
65.Fc
5b2abdfb 66.Ft int
224c7076
A
67.Fo pthread_attr_getschedparam
68.Fa "const pthread_attr_t *restrict attr"
69.Fa "struct sched_param *restrict param"
70.Fc
5b2abdfb 71.Ft int
224c7076
A
72.Fo pthread_attr_getschedpolicy
73.Fa "const pthread_attr_t *restrict attr"
74.Fa "int *restrict policy"
75.Fc
5b2abdfb 76.Ft int
224c7076
A
77.Fo pthread_attr_getscope
78.Fa "const pthread_attr_t *restrict attr"
79.Fa "int *restrict contentionscope"
80.Fc
5b2abdfb 81.Ft int
224c7076
A
82.Fo pthread_attr_getstackaddr
83.Fa "const pthread_attr_t *restrict attr"
84.Fa "void **restrict stackaddr"
85.Fc
5b2abdfb 86.Ft int
224c7076
A
87.Fo pthread_attr_getstacksize
88.Fa "const pthread_attr_t *restrict attr"
89.Fa "size_t *restrict stacksize"
90.Fc
5b2abdfb 91.Ft int
224c7076
A
92.Fo pthread_attr_init
93.Fa "pthread_attr_t *attr"
94.Fc
5b2abdfb 95.Ft int
224c7076
A
96.Fo pthread_attr_setdetachstate
97.Fa "pthread_attr_t *attr"
98.Fa "int detachstate"
99.Fc
5b2abdfb 100.Ft int
224c7076
A
101.Fo pthread_attr_setinheritsched
102.Fa "pthread_attr_t *attr"
103.Fa "int inheritsched"
104.Fc
5b2abdfb 105.Ft int
224c7076
A
106.Fo pthread_attr_setschedparam
107.Fa "pthread_attr_t *restrict attr"
108.Fa "const struct sched_param *restrict param"
109.Fc
5b2abdfb 110.Ft int
224c7076
A
111.Fo pthread_attr_setschedpolicy
112.Fa "pthread_attr_t *attr"
113.Fa "int policy"
114.Fc
5b2abdfb 115.Ft int
224c7076
A
116.Fo pthread_attr_setscope
117.Fa "pthread_attr_t *attr"
118.Fa "int contentionscope"
119.Fc
5b2abdfb 120.Ft int
224c7076
A
121.Fo pthread_attr_setstackaddr
122.Fa "pthread_attr_t *attr"
123.Fa "void *stackaddr"
124.Fc
5b2abdfb 125.Ft int
224c7076
A
126.Fo pthread_attr_setstacksize
127.Fa "pthread_attr_t *attr"
128.Fa "size_t stacksize"
129.Fc
5b2abdfb
A
130.Sh DESCRIPTION
131Thread attributes are used to specify parameters to
132.Fn pthread_create .
133One attribute object can be used in multiple calls to
134.Fn pthread_create ,
135with or without modifications between calls.
136.Pp
137The
138.Fn pthread_attr_init
139function initializes
140.Fa attr
141with all the default thread attributes.
142.Pp
143The
144.Fn pthread_attr_destroy
145function destroys
146.Fa attr .
147.Pp
148The
149.Fn pthread_attr_set*
150functions set the attribute that corresponds to each function name.
151.Pp
152The
153.Fn pthread_attr_get*
154functions copy the value of the attribute that corresponds to each function name
155to the location pointed to by the second function parameter.
156.Sh RETURN VALUES
157If successful, these functions return 0.
158Otherwise, an error number is returned to indicate the error.
159.Sh ERRORS
160.Fn pthread_attr_init
161will fail if:
162.Bl -tag -width Er
224c7076 163.\" ========
5b2abdfb
A
164.It Bq Er ENOMEM
165Out of memory.
166.El
167.Pp
168.Fn pthread_attr_destroy
169will fail if:
170.Bl -tag -width Er
224c7076 171.\" ========
5b2abdfb
A
172.It Bq Er EINVAL
173Invalid value for
174.Fa attr .
175.El
176.Pp
177.Fn pthread_attr_setstacksize
178will fail if:
179.Bl -tag -width Er
224c7076
A
180.\" ========
181.It Bq Er EINVAL
182Invalid value for
183.Fa attr .
184.\" ========
5b2abdfb
A
185.It Bq Er EINVAL
186.Fa stacksize
187is less than
188.Dv PTHREAD_STACK_MIN .
224c7076
A
189.\" ========
190.It Bq Er EINVAL
191.Fa stacksize
192is not a multiple of the system page size.
5b2abdfb
A
193.El
194.Pp
195.Fn pthread_attr_setdetachstate
196will fail if:
197.Bl -tag -width Er
224c7076 198.\" ========
5b2abdfb
A
199.It Bq Er EINVAL
200Invalid value for
224c7076
A
201.Fa attr
202or
5b2abdfb
A
203.Fa detachstate .
204.El
205.Pp
206.Fn pthread_attr_setinheritsched
207will fail if:
208.Bl -tag -width Er
224c7076 209.\" ========
5b2abdfb
A
210.It Bq Er EINVAL
211Invalid value for
212.Fa attr .
213.El
214.Pp
215.Fn pthread_attr_setschedparam
216will fail if:
217.Bl -tag -width Er
224c7076 218.\" ========
5b2abdfb
A
219.It Bq Er EINVAL
220Invalid value for
221.Fa attr .
224c7076 222.\" ========
5b2abdfb
A
223.It Bq Er ENOTSUP
224Invalid value for
225.Fa param .
226.El
227.Pp
228.Fn pthread_attr_setschedpolicy
229will fail if:
230.Bl -tag -width Er
224c7076 231.\" ========
5b2abdfb
A
232.It Bq Er EINVAL
233Invalid value for
234.Fa attr .
235.It Bq Er ENOTSUP
236Invalid or unsupported value for
237.Fa policy .
238.El
239.Pp
240.Fn pthread_attr_setscope
241will fail if:
242.Bl -tag -width Er
224c7076 243.\" ========
5b2abdfb
A
244.It Bq Er EINVAL
245Invalid value for
246.Fa attr .
224c7076 247.\" ========
5b2abdfb
A
248.It Bq Er ENOTSUP
249Invalid or unsupported value for
250.Fa contentionscope .
251.El
252.Sh SEE ALSO
253.Xr pthread_create 3
254.Sh STANDARDS
255.Fn pthread_attr_init ,
256.Fn pthread_attr_destroy ,
257.Fn pthread_attr_setstacksize ,
258.Fn pthread_attr_getstacksize ,
259.Fn pthread_attr_setstackaddr ,
260.Fn pthread_attr_getstackaddr ,
261.Fn pthread_attr_setdetachstate ,
262and
263.Fn pthread_attr_getdetachstate
264conform to
265.St -p1003.1-96
266.Pp
267.Fn pthread_attr_setinheritsched ,
268.Fn pthread_attr_getinheritsched ,
269.Fn pthread_attr_setschedparam ,
270.Fn pthread_attr_getschedparam ,
271.Fn pthread_attr_setschedpolicy ,
272.Fn pthread_attr_getschedpolicy ,
273.Fn pthread_attr_setscope ,
274and
275.Fn pthread_attr_getscope
276conform to
277.St -susv2