1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH PTHREAD_ATTR_SETSCOPE 3 2017-09-15 "Linux" "Linux Programmer's Manual"
28 pthread_attr_setscope, pthread_attr_getscope \- set/get contention scope
29 attribute in thread attributes object
32 .B #include <pthread.h>
34 .BI "int pthread_attr_setscope(pthread_attr_t *" attr \
36 .BI "int pthread_attr_getscope(const pthread_attr_t *" attr \
39 Compile and link with \fI\-pthread\fP.
43 .BR pthread_attr_setscope ()
44 function sets the contention scope attribute of the
45 thread attributes object referred to by
47 to the value specified in
49 The contention scope attribute defines the set of threads
50 against which a thread competes for resources such as the CPU.
51 POSIX.1 specifies two possible values for
54 .B PTHREAD_SCOPE_SYSTEM
55 The thread competes for resources with all other threads
56 in all processes on the system that are in the same scheduling
57 allocation domain (a group of one or more processors).
58 .B PTHREAD_SCOPE_SYSTEM
59 threads are scheduled relative to one another
60 according to their scheduling policy and priority.
62 .B PTHREAD_SCOPE_PROCESS
63 The thread competes for resources with all other threads
64 in the same process that were also created with the
65 .BR PTHREAD_SCOPE_PROCESS
67 .BR PTHREAD_SCOPE_PROCESS
68 threads are scheduled relative to other threads in the process
69 according to their scheduling policy and priority.
70 POSIX.1 leaves it unspecified how these threads contend
71 with other threads in other process on the system or
72 with other threads in the same process that
74 .B PTHREAD_SCOPE_SYSTEM
77 POSIX.1 requires that an implementation support at least one of these
80 .BR PTHREAD_SCOPE_SYSTEM ,
82 .BR PTHREAD_SCOPE_PROCESS .
84 On systems that support multiple contention scopes, then,
85 in order for the parameter setting made by
86 .BR pthread_attr_setscope ()
87 to have effect when calling
88 .BR pthread_create (3),
90 .BR pthread_attr_setinheritsched (3)
91 to set the inherit-scheduler attribute of the attributes object
94 .BR PTHREAD_EXPLICIT_SCHED .
97 .BR pthread_attr_getscope ()
98 function returns the contention scope attribute of the
99 thread attributes object referred to by
101 in the buffer pointed to by
104 On success, these functions return 0;
105 on error, they return a nonzero error number.
107 .BR pthread_attr_setscope ()
108 can fail with the following errors:
111 An invalid value was specified in
117 .BR PTHREAD_SCOPE_PROCESS ,
118 which is not supported on Linux.
120 For an explanation of the terms used in this section, see
126 Interface Attribute Value
128 .BR pthread_attr_setscope (),
129 .BR pthread_attr_getscope ()
130 T} Thread safety MT-Safe
133 POSIX.1-2001, POSIX.1-2008.
136 .B PTHREAD_SCOPE_SYSTEM
137 contention scope typically indicates that a user-space thread is
138 bound directly to a single kernel-scheduling entity.
139 This is the case on Linux for the obsolete LinuxThreads implementation
140 and the modern NPTL implementation,
141 which are both 1:1 threading implementations.
143 POSIX.1 specifies that the default contention scope is
144 implementation-defined.
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),