]>
Commit | Line | Data |
---|---|---|
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 | .\" |
4b8c67d9 | 26 | .TH PTHREAD_ATTR_SETSCOPE 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
693e11d0 MK |
27 | .SH NAME |
28 | pthread_attr_setscope, pthread_attr_getscope \- set/get contention scope | |
29 | attribute in thread attributes object | |
30 | .SH SYNOPSIS | |
31 | .nf | |
32 | .B #include <pthread.h> | |
dbfe9c70 | 33 | .PP |
693e11d0 MK |
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 | 39 | Compile and link with \fI\-pthread\fP. |
6030f2d8 | 40 | .fi |
693e11d0 MK |
41 | .SH DESCRIPTION |
42 | The | |
43 | .BR pthread_attr_setscope () | |
44 | function sets the contention scope attribute of the | |
45 | thread attributes object referred to by | |
46 | .I attr | |
47 | to the value specified in | |
48 | .IR scope . | |
49 | The contention scope attribute defines the set of threads | |
50 | against which a thread competes for resources such as the CPU. | |
7b760db9 | 51 | POSIX.1 specifies two possible values for |
693e11d0 MK |
52 | .IR scope : |
53 | .TP | |
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. | |
61 | .TP | |
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 | |
66 | contention scope. | |
67 | .BR PTHREAD_SCOPE_PROCESS | |
68 | threads are scheduled relative to other threads in the process | |
69 | according to their scheduling policy and priority. | |
7b760db9 | 70 | POSIX.1 leaves it unspecified how these threads contend |
693e11d0 MK |
71 | with other threads in other process on the system or |
72 | with other threads in the same process that | |
73 | were created with the | |
74 | .B PTHREAD_SCOPE_SYSTEM | |
75 | contention scope. | |
76 | .PP | |
7b760db9 | 77 | POSIX.1 requires that an implementation support at least one of these |
6d46d0fa | 78 | contention scopes. |
693e11d0 MK |
79 | Linux supports |
80 | .BR PTHREAD_SCOPE_SYSTEM , | |
81 | but not | |
82 | .BR PTHREAD_SCOPE_PROCESS . | |
847e0d88 | 83 | .PP |
ea22c6e9 MK |
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), | |
89 | the caller must use | |
90 | .BR pthread_attr_setinheritsched (3) | |
91 | to set the inherit-scheduler attribute of the attributes object | |
92 | .I attr | |
93 | to | |
94 | .BR PTHREAD_EXPLICIT_SCHED . | |
847e0d88 | 95 | .PP |
693e11d0 MK |
96 | The |
97 | .BR pthread_attr_getscope () | |
98 | function returns the contention scope attribute of the | |
99 | thread attributes object referred to by | |
100 | .I attr | |
101 | in the buffer pointed to by | |
102 | .IR scope . | |
103 | .SH RETURN VALUE | |
104 | On success, these functions return 0; | |
c7094399 | 105 | on error, they return a nonzero error number. |
693e11d0 MK |
106 | .SH ERRORS |
107 | .BR pthread_attr_setscope () | |
108 | can fail with the following errors: | |
109 | .TP | |
110 | .B EINVAL | |
111 | An invalid value was specified in | |
112 | .IR scope . | |
113 | .TP | |
114 | .B ENOTSUP | |
115 | .IR scope | |
116 | specified the value | |
117 | .BR PTHREAD_SCOPE_PROCESS , | |
118 | which is not supported on Linux. | |
180a948b | 119 | .SH ATTRIBUTES |
ad5c7ea9 PH |
120 | For an explanation of the terms used in this section, see |
121 | .BR attributes (7). | |
122 | .TS | |
123 | allbox; | |
124 | lbw24 lb lb | |
125 | l l l. | |
126 | Interface Attribute Value | |
127 | T{ | |
128 | .BR pthread_attr_setscope (), | |
180a948b | 129 | .BR pthread_attr_getscope () |
ad5c7ea9 PH |
130 | T} Thread safety MT-Safe |
131 | .TE | |
693e11d0 | 132 | .SH CONFORMING TO |
7b760db9 | 133 | POSIX.1-2001, POSIX.1-2008. |
693e11d0 MK |
134 | .SH NOTES |
135 | The | |
136 | .B PTHREAD_SCOPE_SYSTEM | |
7fac88a9 | 137 | contention scope typically indicates that a user-space thread is |
693e11d0 | 138 | bound directly to a single kernel-scheduling entity. |
cc0dac78 | 139 | This is the case on Linux for the obsolete LinuxThreads implementation |
693e11d0 MK |
140 | and the modern NPTL implementation, |
141 | which are both 1:1 threading implementations. | |
847e0d88 | 142 | .PP |
7b760db9 | 143 | POSIX.1 specifies that the default contention scope is |
693e11d0 MK |
144 | implementation-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) |