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