1PTHREAD_ATTR_SETSCOPE(3) Linux Programmer's Manual PTHREAD_ATTR_SETSCOPE(3)
2
3
4
6 pthread_attr_setscope, pthread_attr_getscope - set/get contention scope
7 attribute in thread attributes object
8
10 #include <pthread.h>
11
12 int pthread_attr_setscope(pthread_attr_t *attr, int scope);
13 int pthread_attr_getscope(pthread_attr_t *attr, int *scope);
14
15 Compile and link with -pthread.
16
18 The pthread_attr_setscope() function sets the contention scope
19 attribute of the thread attributes object referred to by attr to the
20 value specified in scope. The contention scope attribute defines the
21 set of threads against which a thread competes for resources such as
22 the CPU. POSIX.1-2001 specifies two possible values for scope:
23
24 PTHREAD_SCOPE_SYSTEM
25 The thread competes for resources with all other threads in all
26 processes on the system that are in the same scheduling alloca‐
27 tion domain (a group of one or more processors).
28 PTHREAD_SCOPE_SYSTEM threads are scheduled relative to one
29 another according to their scheduling policy and priority.
30
31 PTHREAD_SCOPE_PROCESS
32 The thread competes for resources with all other threads in the
33 same process that were also created with the
34 PTHREAD_SCOPE_PROCESS contention scope. PTHREAD_SCOPE_PROCESS
35 threads are scheduled relative to other threads in the process
36 according to their scheduling policy and priority. POSIX.1-2001
37 leaves it unspecified how these threads contend with other
38 threads in other process on the system or with other threads in
39 the same process that were created with the PTHREAD_SCOPE_SYSTEM
40 contention scope.
41
42 POSIX.1-2001 only requires that an implementation support one of these
43 contention scopes, but permits both to be supported. Linux supports
44 PTHREAD_SCOPE_SYSTEM, but not PTHREAD_SCOPE_PROCESS.
45
46 The pthread_attr_getscope() function returns the contention scope
47 attribute of the thread attributes object referred to by attr in the
48 buffer pointed to by scope.
49
51 On success, these functions return 0; on error, they return a non-zero
52 error number.
53
55 pthread_attr_setscope() can fail with the following errors:
56
57 EINVAL An invalid value was specified in scope.
58
59 ENOTSUP
60 scope specified the value PTHREAD_SCOPE_PROCESS, which is not
61 supported on Linux.
62
64 POSIX.1-2001.
65
67 The PTHREAD_SCOPE_SYSTEM contention scope typically indicates that a
68 userspace thread is bound directly to a single kernel-scheduling
69 entity. This is the case on Linux for the obsolete LinuxThreads imple‐
70 mentation and the modern NPTL implementation, which are both 1:1
71 threading implementations.
72
73 POSIX.1-2001 specifies that the default contention scope is implementa‐
74 tion-defined.
75
77 pthread_attr_init(3), pthread_attr_setaffinity_np(3), pthread_attr_set‐
78 inheritsched(3), pthread_attr_setschedparam(3), pthread_attr_setsched‐
79 policy(3), pthread_create(3), pthreads(7)
80
82 This page is part of release 3.22 of the Linux man-pages project. A
83 description of the project, and information about reporting bugs, can
84 be found at http://www.kernel.org/doc/man-pages/.
85
86
87
88Linux 2008-10-24 PTHREAD_ATTR_SETSCOPE(3)