xref: /netbsd-src/lib/libpthread/pthread_attr.3 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\" $NetBSD: pthread_attr.3,v 1.3 2003/06/26 10:01:18 wiz Exp $
2.\"
3.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. Neither the name of The NetBSD Foundation nor the names of its
14.\"    contributors may be used to endorse or promote products derived
15.\"    from this software without specific prior written permission.
16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20.\" BE 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 BUSINESS
23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26.\" POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
29.\" All rights reserved.
30.\"
31.\" Redistribution and use in source and binary forms, with or without
32.\" modification, are permitted provided that the following conditions
33.\" are met:
34.\" 1. Redistributions of source code must retain the above copyright
35.\"    notice(s), this list of conditions and the following disclaimer as
36.\"    the first lines of this file unmodified other than the possible
37.\"    addition of one or more copyright notices.
38.\" 2. Redistributions in binary form must reproduce the above copyright
39.\"    notice(s), this list of conditions and the following disclaimer in
40.\"    the documentation and/or other materials provided with the
41.\"    distribution.
42.\"
43.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
44.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
47.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
48.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
50.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
52.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54.\"
55.\" $FreeBSD: src/lib/libpthread/man/pthread_attr.3,v 1.11 2002/09/16 19:29:28 mini Exp $
56.Dd January 30, 2003
57.Dt PTHREAD_ATTR 3
58.Os
59.Sh NAME
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
79.Sh LIBRARY
80.Lb libpthread
81.Sh SYNOPSIS
82.In pthread.h
83.Ft int
84.Fn pthread_attr_init "pthread_attr_t *attr"
85.Ft int
86.Fn pthread_attr_destroy "pthread_attr_t *attr"
87./" .Ft int
88./" .Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize"
89./" .Ft int
90./" .Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize"
91./" .Ft int
92./" .Fn pthread_attr_setguardsize "pthread_attr_t *attr" "size_t guardsize"
93./" .Ft int
94./" .Fn pthread_attr_getguardsize "const pthread_attr_t *attr" "size_t *guardsize"
95./" .Ft int
96./" .Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr"
97./" .Ft int
98./" .Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr"
99.Ft int
100.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
101.Ft int
102.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate"
103./" .Ft int
104./" .Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched"
105./" .Ft int
106./" .Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched"
107.Ft int
108.Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param"
109.Ft int
110.Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param"
111./" .Ft int
112./" .Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy"
113./" .Ft int
114./" .Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy"
115./" .Ft int
116./" .Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope"
117./" .Ft int
118./" .Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope"
119.Sh DESCRIPTION
120Thread attributes are used to specify parameters to
121.Fn pthread_create .
122One attribute object can be used in multiple calls to
123.Fn pthread_create ,
124with or without modifications between calls.
125.Pp
126The
127.Fn pthread_attr_init
128function initializes
129.Fa attr
130with all the default thread attributes.
131.Pp
132The
133.Fn pthread_attr_destroy
134function destroys
135.Fa attr .
136.Pp
137The
138.Fn pthread_attr_set*
139functions set the attribute that corresponds to each function name.
140.Pp
141The
142.Fn pthread_attr_get*
143functions copy the value of the attribute that corresponds to each function name
144to the location pointed to by the second function parameter.
145.Sh RETURN VALUES
146If successful, these functions return 0.
147Otherwise, an error number is returned to indicate the error.
148.Sh ERRORS
149.Fn pthread_attr_init
150shall fail if:
151.Bl -tag -width Er
152.It Bq Er ENOMEM
153Out of memory.
154.El
155.Pp
156.Fn pthread_attr_destroy
157may fail if:
158.Bl -tag -width Er
159.It Bq Er EINVAL
160The value specified by
161.Fa attr
162is invalid.
163.El
164.Pp
165.\" .Fn pthread_attr_setstacksize
166.\" may fail if:
167.\" .Bl -tag -width Er
168.\" .It Bq Er EINVAL
169.\" .Fa stacksize
170.\" is less than
171.\" .Dv PTHREAD_STACK_MIN .
172.\" .El
173.\" .Pp
174.Fn pthread_attr_setdetachstate
175shall fail if:
176.Bl -tag -width Er
177.It Bq Er EINVAL
178The value specified by
179.Fa detachstate
180is invalid.
181.El
182.Pp
183.\" Fn pthread_attr_setinheritsched
184.\" may fail if:
185.\" .Bl -tag -width Er
186.\" .It Bq Er EINVAL
187.\" Invalid value for
188.\" .Fa attr .
189.\" .El
190.\" .Pp
191.Fn pthread_attr_setschedparam
192may fail if:
193.Bl -tag -width Er
194.It Bq Er EINVAL
195The value specified by
196.Fa attr
197is invalid.
198.It Bq Er ENOTSUP
199The value specified by
200.Fa param
201is invalid.
202.El
203.Pp
204.\" .Fn pthread_attr_setschedpolicy
205.\" may fail if:
206.\" .Bl -tag -width Er
207.\" .It Bq Er EINVAL
208.\" Invalid value for
209.\" .Fa attr .
210.\" .It Bq Er ENOTSUP
211.\" Invalid or unsupported value for
212.\" .Fa policy .
213.\" .El
214.\" .Pp
215.\" .Fn pthread_attr_setscope
216.\" may fail if:
217.\" .Bl -tag -width Er
218.\" .It Bq Er EINVAL
219.\" Invalid value for
220.\" .Fa attr .
221.\" .It Bq Er ENOTSUP
222.\" Invalid or unsupported value for
223.\" .Fa contentionscope .
224.\" .El
225.Sh SEE ALSO
226.Xr pthread_create 3
227.Sh STANDARDS
228.Fn pthread_attr_init ,
229.Fn pthread_attr_destroy ,
230.\" .Fn pthread_attr_setstacksize ,
231.\" .Fn pthread_attr_getstacksize ,
232.\" .Fn pthread_attr_setstackaddr ,
233.\" .Fn pthread_attr_getstackaddr ,
234.Fn pthread_attr_setdetachstate ,
235.Fn pthread_attr_getdetachstate ,
236.\" .Fn pthread_attr_setinheritsched ,
237.\" .Fn pthread_attr_getinheritsched ,
238.\" .Fn pthread_attr_setschedparam ,
239.Fn pthread_attr_setschedparam ,
240and
241.Fn pthread_attr_getschedparam
242.\" .Fn pthread_attr_setschedpolicy ,
243.\" .Fn pthread_attr_getschedpolicy ,
244.\" .Fn pthread_attr_setscope ,
245.\" and
246.\" .Fn pthread_attr_getscope
247conform to
248.St -p1003.1-96 .
249