]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_attr_setscope.3
_exit.2, bpf.2, cacheflush.2, capget.2, chdir.2, chmod.2, chroot.2, clock_getres...
[thirdparty/man-pages.git] / man3 / pthread_attr_setscope.3
CommitLineData
693e11d0
MK
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
693e11d0
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
693e11d0 25.\"
460495ca 26.TH PTHREAD_ATTR_SETSCOPE 3 2015-08-08 "Linux" "Linux Programmer's Manual"
693e11d0
MK
27.SH NAME
28pthread_attr_setscope, pthread_attr_getscope \- set/get contention scope
29attribute in thread attributes object
30.SH SYNOPSIS
31.nf
32.B #include <pthread.h>
33
34.BI "int pthread_attr_setscope(pthread_attr_t *" attr \
35", int " scope );
e59f5f58 36.BI "int pthread_attr_getscope(const pthread_attr_t *" attr \
693e11d0 37", int *" scope );
68e4db0a 38.PP
693e11d0 39Compile and link with \fI\-pthread\fP.
6030f2d8 40.fi
693e11d0
MK
41.SH DESCRIPTION
42The
43.BR pthread_attr_setscope ()
44function sets the contention scope attribute of the
45thread attributes object referred to by
46.I attr
47to the value specified in
48.IR scope .
49The contention scope attribute defines the set of threads
50against which a thread competes for resources such as the CPU.
7b760db9 51POSIX.1 specifies two possible values for
693e11d0
MK
52.IR scope :
53.TP
54.B PTHREAD_SCOPE_SYSTEM
55The thread competes for resources with all other threads
56in all processes on the system that are in the same scheduling
57allocation domain (a group of one or more processors).
58.B PTHREAD_SCOPE_SYSTEM
59threads are scheduled relative to one another
60according to their scheduling policy and priority.
61.TP
62.B PTHREAD_SCOPE_PROCESS
63The thread competes for resources with all other threads
64in the same process that were also created with the
65.BR PTHREAD_SCOPE_PROCESS
66contention scope.
67.BR PTHREAD_SCOPE_PROCESS
68threads are scheduled relative to other threads in the process
69according to their scheduling policy and priority.
7b760db9 70POSIX.1 leaves it unspecified how these threads contend
693e11d0
MK
71with other threads in other process on the system or
72with other threads in the same process that
73were created with the
74.B PTHREAD_SCOPE_SYSTEM
75contention scope.
76.PP
7b760db9 77POSIX.1 requires that an implementation support at least one of these
6d46d0fa 78contention scopes.
693e11d0
MK
79Linux supports
80.BR PTHREAD_SCOPE_SYSTEM ,
81but not
82.BR PTHREAD_SCOPE_PROCESS .
83
ea22c6e9
MK
84On systems that support multiple contention scopes, then,
85in order for the parameter setting made by
86.BR pthread_attr_setscope ()
87to have effect when calling
88.BR pthread_create (3),
89the caller must use
90.BR pthread_attr_setinheritsched (3)
91to set the inherit-scheduler attribute of the attributes object
92.I attr
93to
94.BR PTHREAD_EXPLICIT_SCHED .
95
693e11d0
MK
96The
97.BR pthread_attr_getscope ()
98function returns the contention scope attribute of the
99thread attributes object referred to by
100.I attr
101in the buffer pointed to by
102.IR scope .
103.SH RETURN VALUE
104On success, these functions return 0;
c7094399 105on error, they return a nonzero error number.
693e11d0
MK
106.SH ERRORS
107.BR pthread_attr_setscope ()
108can fail with the following errors:
109.TP
110.B EINVAL
111An invalid value was specified in
112.IR scope .
113.TP
114.B ENOTSUP
115.IR scope
116specified the value
117.BR PTHREAD_SCOPE_PROCESS ,
118which is not supported on Linux.
180a948b 119.SH ATTRIBUTES
ad5c7ea9
PH
120For an explanation of the terms used in this section, see
121.BR attributes (7).
122.TS
123allbox;
124lbw24 lb lb
125l l l.
126Interface Attribute Value
127T{
128.BR pthread_attr_setscope (),
180a948b 129.BR pthread_attr_getscope ()
ad5c7ea9
PH
130T} Thread safety MT-Safe
131.TE
693e11d0 132.SH CONFORMING TO
7b760db9 133POSIX.1-2001, POSIX.1-2008.
693e11d0
MK
134.SH NOTES
135The
136.B PTHREAD_SCOPE_SYSTEM
7fac88a9 137contention scope typically indicates that a user-space thread is
693e11d0 138bound directly to a single kernel-scheduling entity.
cc0dac78 139This is the case on Linux for the obsolete LinuxThreads implementation
693e11d0
MK
140and the modern NPTL implementation,
141which are both 1:1 threading implementations.
142
7b760db9 143POSIX.1 specifies that the default contention scope is
693e11d0
MK
144implementation-defined.
145.SH SEE ALSO
ca8a0bd2
MK
146.ad l
147.nh
693e11d0
MK
148.BR pthread_attr_init (3),
149.BR pthread_attr_setaffinity_np (3),
150.BR pthread_attr_setinheritsched (3),
151.BR pthread_attr_setschedparam (3),
152.BR pthread_attr_setschedpolicy (3),
153.BR pthread_create (3),
154.BR pthreads (7)