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