1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .TH PTHREAD_ATTR_SETSCOPE 3 2008-10-24 "Linux" "Linux Programmer's Manual"
26 pthread_attr_setscope, pthread_attr_getscope \- set/get contention scope
27 attribute in thread attributes object
30 .B #include <pthread.h>
32 .BI "int pthread_attr_setscope(pthread_attr_t *" attr \
34 .BI "int pthread_attr_getscope(pthread_attr_t *" attr \
37 Compile and link with \fI\-pthread\fP.
41 .BR pthread_attr_setscope ()
42 function sets the contention scope attribute of the
43 thread attributes object referred to by
45 to the value specified in
47 The contention scope attribute defines the set of threads
48 against which a thread competes for resources such as the CPU.
49 POSIX.1-2001 specifies two possible values for
52 .B PTHREAD_SCOPE_SYSTEM
53 The thread competes for resources with all other threads
54 in all processes on the system that are in the same scheduling
55 allocation domain (a group of one or more processors).
56 .B PTHREAD_SCOPE_SYSTEM
57 threads are scheduled relative to one another
58 according to their scheduling policy and priority.
60 .B PTHREAD_SCOPE_PROCESS
61 The thread competes for resources with all other threads
62 in the same process that were also created with the
63 .BR PTHREAD_SCOPE_PROCESS
65 .BR PTHREAD_SCOPE_PROCESS
66 threads are scheduled relative to other threads in the process
67 according to their scheduling policy and priority.
68 POSIX.1-2001 leaves it unspecified how these threads contend
69 with other threads in other process on the system or
70 with other threads in the same process that
72 .B PTHREAD_SCOPE_SYSTEM
75 POSIX.1-2001 only requires that an implementation support one of these
76 contention scopes, but permits both to be supported.
78 .BR PTHREAD_SCOPE_SYSTEM ,
80 .BR PTHREAD_SCOPE_PROCESS .
83 .BR pthread_attr_getscope ()
84 function returns the contention scope attribute of the
85 thread attributes object referred to by
87 in the buffer pointed to by
90 On success, these functions return 0;
91 on error, they return a nonzero error number.
93 .BR pthread_attr_setscope ()
94 can fail with the following errors:
97 An invalid value was specified in
103 .BR PTHREAD_SCOPE_PROCESS ,
104 which is not supported on Linux.
109 .B PTHREAD_SCOPE_SYSTEM
110 contention scope typically indicates that a userspace thread is
111 bound directly to a single kernel-scheduling entity.
112 This is the case on Linux for the obsolete LinuxThreads implementation
113 and the modern NPTL implementation,
114 which are both 1:1 threading implementations.
116 POSIX.1-2001 specifies that the default contention scope is
117 implementation-defined.
119 .BR pthread_attr_init (3),
120 .BR pthread_attr_setaffinity_np (3),
121 .BR pthread_attr_setinheritsched (3),
122 .BR pthread_attr_setschedparam (3),
123 .BR pthread_attr_setschedpolicy (3),
124 .BR pthread_create (3),