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