OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_attr_setscope.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_ATTR_SETSCOPE 3 2008-10-24 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_attr_setscope, pthread_attr_getscope \- set/get contention scope
27 attribute in thread attributes object
28 .SH SYNOPSIS
29 .nf
30 .B #include <pthread.h>
31
32 .BI "int pthread_attr_setscope(pthread_attr_t *" attr \
33 ", int " scope );
34 .BI "int pthread_attr_getscope(pthread_attr_t *" attr \
35 ", int *" scope );
36 .sp
37 Compile and link with \fI\-pthread\fP.
38 .fi
39 .SH DESCRIPTION
40 The
41 .BR pthread_attr_setscope ()
42 function sets the contention scope attribute of the
43 thread attributes object referred to by
44 .I attr
45 to the value specified in
46 .IR scope .
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
50 .IR scope :
51 .TP
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.
59 .TP
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
64 contention scope.
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
71 were created with the
72 .B PTHREAD_SCOPE_SYSTEM
73 contention scope.
74 .PP
75 POSIX.1-2001 only requires that an implementation support one of these
76 contention scopes, but permits both to be supported.
77 Linux supports
78 .BR PTHREAD_SCOPE_SYSTEM ,
79 but not
80 .BR PTHREAD_SCOPE_PROCESS .
81
82 The
83 .BR pthread_attr_getscope ()
84 function returns the contention scope attribute of the
85 thread attributes object referred to by
86 .I attr
87 in the buffer pointed to by
88 .IR scope .
89 .SH RETURN VALUE
90 On success, these functions return 0;
91 on error, they return a nonzero error number.
92 .SH ERRORS
93 .BR pthread_attr_setscope ()
94 can fail with the following errors:
95 .TP
96 .B EINVAL
97 An invalid value was specified in
98 .IR scope .
99 .TP
100 .B ENOTSUP
101 .IR scope
102 specified the value
103 .BR PTHREAD_SCOPE_PROCESS ,
104 which is not supported on Linux.
105 .SH CONFORMING TO
106 POSIX.1-2001.
107 .SH NOTES
108 The
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.
115
116 POSIX.1-2001 specifies that the default contention scope is
117 implementation-defined.
118 .SH SEE ALSO
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),
125 .BR pthreads (7)