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