]> git.saurik.com Git - apple/libc.git/blame - pthreads/pthread_attr.3
Libc-391.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
33.Nm pthread_attr_init ,
34.Nm pthread_attr_destroy ,
35.Nm pthread_attr_setstacksize ,
36.Nm pthread_attr_getstacksize ,
37.Nm pthread_attr_setstackaddr ,
38.Nm pthread_attr_getstackaddr ,
39.Nm pthread_attr_setdetachstate ,
40.Nm pthread_attr_getdetachstate ,
41.Nm pthread_attr_setinheritsched ,
42.Nm pthread_attr_getinheritsched ,
43.Nm pthread_attr_setschedparam ,
44.Nm pthread_attr_getschedparam ,
45.Nm pthread_attr_setschedpolicy ,
46.Nm pthread_attr_getschedpolicy ,
47.Nm pthread_attr_setscope ,
48.Nm pthread_attr_getscope
49.Nd thread attribute operations
50.Sh SYNOPSIS
51.Fd #include <pthread.h>
52.Ft int
53.Fn pthread_attr_init "pthread_attr_t *attr"
54.Ft int
55.Fn pthread_attr_destroy "pthread_attr_t *attr"
56.Ft int
57.Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize"
58.Ft int
59.Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize"
60.Ft int
61.Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr"
62.Ft int
63.Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr"
64.Ft int
65.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
66.Ft int
67.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate"
68.Ft int
69.Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched"
70.Ft int
71.Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched"
72.Ft int
73.Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param"
74.Ft int
75.Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param"
76.Ft int
77.Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy"
78.Ft int
79.Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy"
80.Ft int
81.Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope"
82.Ft int
83.Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope"
84.Sh DESCRIPTION
85Thread attributes are used to specify parameters to
86.Fn pthread_create .
87One attribute object can be used in multiple calls to
88.Fn pthread_create ,
89with or without modifications between calls.
90.Pp
91The
92.Fn pthread_attr_init
93function initializes
94.Fa attr
95with all the default thread attributes.
96.Pp
97The
98.Fn pthread_attr_destroy
99function destroys
100.Fa attr .
101.Pp
102The
103.Fn pthread_attr_set*
104functions set the attribute that corresponds to each function name.
105.Pp
106The
107.Fn pthread_attr_get*
108functions copy the value of the attribute that corresponds to each function name
109to the location pointed to by the second function parameter.
110.Sh RETURN VALUES
111If successful, these functions return 0.
112Otherwise, an error number is returned to indicate the error.
113.Sh ERRORS
114.Fn pthread_attr_init
115will fail if:
116.Bl -tag -width Er
117.It Bq Er ENOMEM
118Out of memory.
119.El
120.Pp
121.Fn pthread_attr_destroy
122will fail if:
123.Bl -tag -width Er
124.It Bq Er EINVAL
125Invalid value for
126.Fa attr .
127.El
128.Pp
129.Fn pthread_attr_setstacksize
130will fail if:
131.Bl -tag -width Er
132.It Bq Er EINVAL
133.Fa stacksize
134is less than
135.Dv PTHREAD_STACK_MIN .
136.El
137.Pp
138.Fn pthread_attr_setdetachstate
139will fail if:
140.Bl -tag -width Er
141.It Bq Er EINVAL
142Invalid value for
143.Fa detachstate .
144.El
145.Pp
146.Fn pthread_attr_setinheritsched
147will fail if:
148.Bl -tag -width Er
149.It Bq Er EINVAL
150Invalid value for
151.Fa attr .
152.El
153.Pp
154.Fn pthread_attr_setschedparam
155will fail if:
156.Bl -tag -width Er
157.It Bq Er EINVAL
158Invalid value for
159.Fa attr .
160.It Bq Er ENOTSUP
161Invalid value for
162.Fa param .
163.El
164.Pp
165.Fn pthread_attr_setschedpolicy
166will fail if:
167.Bl -tag -width Er
168.It Bq Er EINVAL
169Invalid value for
170.Fa attr .
171.It Bq Er ENOTSUP
172Invalid or unsupported value for
173.Fa policy .
174.El
175.Pp
176.Fn pthread_attr_setscope
177will fail if:
178.Bl -tag -width Er
179.It Bq Er EINVAL
180Invalid value for
181.Fa attr .
182.It Bq Er ENOTSUP
183Invalid or unsupported value for
184.Fa contentionscope .
185.El
186.Sh SEE ALSO
187.Xr pthread_create 3
188.Sh STANDARDS
189.Fn pthread_attr_init ,
190.Fn pthread_attr_destroy ,
191.Fn pthread_attr_setstacksize ,
192.Fn pthread_attr_getstacksize ,
193.Fn pthread_attr_setstackaddr ,
194.Fn pthread_attr_getstackaddr ,
195.Fn pthread_attr_setdetachstate ,
196and
197.Fn pthread_attr_getdetachstate
198conform to
199.St -p1003.1-96
200.Pp
201.Fn pthread_attr_setinheritsched ,
202.Fn pthread_attr_getinheritsched ,
203.Fn pthread_attr_setschedparam ,
204.Fn pthread_attr_getschedparam ,
205.Fn pthread_attr_setschedpolicy ,
206.Fn pthread_attr_getschedpolicy ,
207.Fn pthread_attr_setscope ,
208and
209.Fn pthread_attr_getscope
210conform to
211.St -susv2