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 122.Fn pthread_attr_init 123will fail if: 124.Bl -tag -width Er 125.It Bq Er ENOMEM 126Out of memory. 127.El 128.Pp 129.Fn pthread_attr_destroy 130will fail if: 131.Bl -tag -width Er 132.It Bq Er EINVAL 133Invalid value for 134.Fa attr . 135.El 136.Pp 137.Fn pthread_attr_setstacksize 138will fail if: 139.Bl -tag -width Er 140.It Bq Er EINVAL 141.Fa stacksize 142is less than 143.Dv PTHREAD_STACK_MIN . 144.El 145.Pp 146.Fn pthread_attr_setdetachstate 147will fail if: 148.Bl -tag -width Er 149.It Bq Er EINVAL 150Invalid value for 151.Fa detachstate . 152.El 153.Pp 154.Fn pthread_attr_setinheritsched 155will fail if: 156.Bl -tag -width Er 157.It Bq Er EINVAL 158Invalid value for 159.Fa attr . 160.El 161.Pp 162.Fn pthread_attr_setschedparam 163will fail if: 164.Bl -tag -width Er 165.It Bq Er EINVAL 166Invalid value for 167.Fa attr . 168.It Bq Er ENOTSUP 169Invalid value for 170.Fa param . 171.El 172.Pp 173.Fn pthread_attr_setschedpolicy 174will fail if: 175.Bl -tag -width Er 176.It Bq Er EINVAL 177Invalid value for 178.Fa attr . 179.It Bq Er ENOTSUP 180Invalid or unsupported value for 181.Fa policy . 182.El 183.Pp 184.Fn pthread_attr_setscope 185will fail if: 186.Bl -tag -width Er 187.It Bq Er EINVAL 188Invalid value for 189.Fa attr . 190.It Bq Er ENOTSUP 191Invalid or unsupported value for 192.Fa contentionscope . 193.El 194.Sh SEE ALSO 195.Xr pthread_create 3 196.Sh STANDARDS 197.Fn pthread_attr_init , 198.Fn pthread_attr_destroy , 199.Fn pthread_attr_setstacksize , 200.Fn pthread_attr_getstacksize , 201.Fn pthread_attr_setstackaddr , 202.Fn pthread_attr_getstackaddr , 203.Fn pthread_attr_setdetachstate , 204and 205.Fn pthread_attr_getdetachstate 206conform to 207.St -p1003.1-96 208.Pp 209.Fn pthread_attr_setinheritsched , 210.Fn pthread_attr_getinheritsched , 211.Fn pthread_attr_setschedparam , 212.Fn pthread_attr_getschedparam , 213.Fn pthread_attr_setschedpolicy , 214.Fn pthread_attr_getschedpolicy , 215.Fn pthread_attr_setscope , 216and 217.Fn pthread_attr_getscope 218conform to 219.St -susv2 220