1.\" $NetBSD: pthread_attr_getscope.3,v 1.4 2017/10/23 01:03:23 wiz Exp $ 2.\" 3.\" Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20.\" BE 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 BUSINESS 23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26.\" POSSIBILITY OF SUCH DAMAGE. 27.\" 28.Dd July 7, 2010 29.Dt PTHREAD_ATTR_GETSCOPE 3 30.Os 31.Sh NAME 32.Nm pthread_attr_getscope , 33.Nm pthread_attr_setscope 34.Nd get and set the contention scope attribute 35.Sh LIBRARY 36.Lb libpthread 37.Sh SYNOPSIS 38.In pthread.h 39.Ft int 40.Fn pthread_attr_getscope \ 41"const pthread_attr_t * restrict attr" "int * restrict contentionscope" 42.Ft int 43.Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" 44.Sh DESCRIPTION 45The 46.Fn pthread_attr_getscope 47and 48.Fn pthread_attr_setscope 49functions get and set, respectively, the contention scope attribute in the 50.Fa attr 51object. 52.Pp 53The 54.Fa contentionscope 55parameter specifies the scheduling contention scope of a thread. 56It is only possible to set the scope of a thread before the thread is created. 57There are two possible contention scopes: 58.Bl -tag -width PTHREAD_SCOPE_PROCESS -offset 2n 59.It Dv PTHREAD_SCOPE_SYSTEM 60The thread will contend for CPU 61resources with all other processes and threads in the system. 62Generally this means that the user thread is bound directly to the 63kernel scheduling for its entire lifetime. 64.It Dv PTHREAD_SCOPE_PROCESS 65The thread will contend with other threads with the same scope attribute. 66In general, this means that all 67.Dv PTHREAD_SCOPE_PROCESS 68threads are grouped together and this group of threads contends for 69CPU resources. 70This is commonly seen to require a hybrid 71.Pq Dq M:N 72threading model in order to multiplex the user and kernel space scheduling. 73.El 74.Pp 75Only 76.Dv PTHREAD_SCOPE_SYSTEM 77is supported in 78.Nx . 79.Sh RETURN VALUES 80Upon successful completion, both functions return 0. 81Otherwise an error number is returned to indicate the error. 82.Sh ERRORS 83No errors are defined for 84.Fn pthread_attr_getscope . 85.Pp 86The 87.Fn pthread_attr_setscope 88function shall fail if: 89.Bl -tag -width Er 90.It Bq Er EINVAL 91Invalid parameter. 92.El 93.Sh SEE ALSO 94.Xr pthread_attr 3 , 95.Xr csf 9 96.Sh STANDARDS 97Both functions conform to 98.St -p1003.1-96 . 99