xref: /netbsd-src/lib/libpthread/pthread_attr_getscope.3 (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1.\" $NetBSD: pthread_attr_getscope.3,v 1.2 2010/07/07 10:22:33 njoly 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.Nd get and set the contention scope attribute
34.Sh LIBRARY
35.Lb libpthread
36.Sh SYNOPSIS
37.In pthread.h
38.Ft int
39.Fn pthread_attr_getscope \
40"const pthread_attr_t * restrict attr" "int * restrict contentionscope"
41.Ft int
42.Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope"
43.Sh DESCRIPTION
44The
45.Fn pthread_attr_getscope
46and
47.Fn pthread_attr_setscope
48functions get and set, respectively, the contention scope attribute in the
49.Fa attr
50object.
51.Pp
52The
53.Fa contentionscope
54parameter specifies the scheduling contention scope of a thread.
55It is only possible to set the scope of a thread before the thread is created.
56There are two possible contention scopes:
57.Bl -tag -width PTHREAD_SCOPE_PROCESS -offset 2n
58.It Dv PTHREAD_SCOPE_SYSTEM
59The thread will contend for
60.Tn 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
69.Tn CPU
70resources.
71This is commonly seen to require a hybrid
72.Pq Dq M:N
73threading model in order to multiplex the user and kernel space scheduling.
74.El
75.Pp
76Only
77.Dv PTHREAD_SCOPE_SYSTEM
78is supported in
79.Nx .
80.Sh RETURN VALUES
81Upon successful completion, both functions return 0.
82Otherwise an error number is returned to indicate the error.
83.Sh ERRORS
84No errors are defined for
85.Fn pthread_attr_getscope .
86.Pp
87The
88.Fn pthread_attr_setscope
89function shall fail if:
90.Bl -tag -width Er
91.It Bq Er EINVAL
92Invalid parameter.
93.El
94.Sh SEE ALSO
95.Xr pthread_attr 3 ,
96.Xr csf 9
97.Sh STANDARDS
98Both functions conform to
99.St -p1003.1-96 .
100