OSDN Git Service

(split) LDP v3.30, v3.31 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man2 / sched_setaffinity.2
1 .\" man2/sched_setaffinity.2 - sched_setaffinity and sched_getaffinity man page
2 .\"
3 .\" Copyright (C) 2002 Robert Love
4 .\" and Copyright (C) 2006 Michael Kerrisk
5 .\"
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
10 .\"
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
15 .\"
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 .\" GNU General Public License for more details.
20 .\"
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, write to the Free
23 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
24 .\" USA.
25 .\"
26 .\" 2002-11-19 Robert Love <rml@tech9.net> - initial version
27 .\" 2004-04-20 mtk - fixed description of return value
28 .\" 2004-04-22 aeb - added glibc prototype history
29 .\" 2005-05-03 mtk - noted that sched_setaffinity may cause thread
30 .\"     migration and that CPU affinity is a per-thread attribute.
31 .\" 2006-02-03 mtk -- Major rewrite
32 .\" 2008-11-12, mtk, removed CPU_*() macro descriptions to a
33 .\" separate CPU_SET(3) page.
34 .\"
35 .\" Japanese Version Copyright (c) 2003, 2005 Yuichi SATO
36 .\"         all rights reserved.
37 .\" Translated 2003-01-23, Yuichi SATO <ysato444@yahoo.co.jp>
38 .\" Updated & Modified 2003-09-23, Yuichi SATO
39 .\" Updated & Modified 2005-01-03, Yuichi SATO
40 .\" Updated & Modified 2005-09-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
41 .\" Updated & Modified 2006-07-14, Akihiro MOTOKI, LDP v2.34
42 .\" Updated & Modified 2008-12-24, Akihiro MOTOKI, LDP v3.14
43 .\"
44 .\"WORD:        affinity                ¿ÆÏÂÅÙ
45 .\"WORD:        most significant bit    ºÇ¾å°Ì¥Ó¥Ã¥È
46 .\"WORD:        least significant bit   ºÇ²¼°Ì¥Ó¥Ã¥È
47 .\"WORD:        capability              ¸¢¸Â
48 .\"
49 .TH SCHED_SETAFFINITY 2 2010-11-06 "Linux" "Linux Programmer's Manual"
50 .\"O .SH NAME
51 .SH Ì¾Á°
52 .\"O sched_setaffinity, sched_getaffinity \- \
53 .\"O set and get a process's CPU affinity mask
54 sched_setaffinity, sched_getaffinity \- \
55 ¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤òÀßÄꡦ¼èÆÀ¤¹¤ë
56 .\"O .SH SYNOPSIS
57 .SH ½ñ¼°
58 .nf
59 .\"O .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
60 .BR "#define _GNU_SOURCE" "             /* feature_test_macros(7) »²¾È */"
61 .B #include <sched.h>
62 .sp
63 .BI "int sched_setaffinity(pid_t " pid ", size_t " cpusetsize ,
64 .BI "                      cpu_set_t *" mask );
65 .sp
66 .BI "int sched_getaffinity(pid_t " pid ", size_t " cpusetsize ,
67 .BI "                      cpu_set_t *" mask );
68 .fi
69 .\"O .SH DESCRIPTION
70 .SH ÀâÌÀ
71 .\"Osato:
72 .\"Osato: Kernel ¥É¥­¥å¥á¥ó¥È IRQ-affinity.txt ¤ÎÌõ¤Ç¤Ï¡¢
73 .\"Osato: "affinity" ¤Ï¡Ö¥¢¥Õ¥£¥Ë¥Æ¥£¡×¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢
74 .\"Osato: ¤³¤³¤Ë°ì²ó¤À¤±Ìõ¸ì (¿ÆÏÂÅÙ) ¤òÆþ¤ì¤Æ¤ª¤¯¤À¤±¤Ç¡¢
75 .\"Osato: ÆäËÌõ¤µ¤Ê¤¤¤³¤È¤Ë¤·¤è¤¦¤È»×¤¤¤Þ¤¹¡£
76 .\"Osato:
77 .\"O A process's CPU affinity mask determines the set of CPUs on which
78 .\"O it is eligible to run.
79 .\"O On a multiprocessor system, setting the CPU affinity mask
80 .\"O can be used to obtain performance benefits.
81 .\"O For example,
82 .\"O by dedicating one CPU to a particular process
83 .\"O (i.e., setting the affinity mask of that process to specify a single CPU,
84 .\"O and setting the affinity mask of all other processes to exclude that CPU),
85 .\"O it is possible to ensure maximum execution speed for that process.
86 .\"O Restricting a process to run on a single CPU also avoids
87 .\"O the performance cost caused by the cache invalidation that occurs
88 .\"O when a process ceases to execute on one CPU and then
89 .\"O recommences execution on a different CPU.
90 ¥×¥í¥»¥¹¤Î CPU affinity (¿ÆÏÂÅÙ) ¥Þ¥¹¥¯¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤¬
91 ¼Â¹Ô¤òµö²Ä¤µ¤ì¤Æ¤¤¤ë CPU ¤Î½¸¹ç¤ò·èÄꤹ¤ë¡£
92 ¥Þ¥ë¥Á¥×¥í¥»¥Ã¥µ¡¦¥·¥¹¥Æ¥à¤Ç¤Ï¡¢CPU affinity ¥Þ¥¹¥¯¤òÀßÄꤹ¤ë¤³¤È¤Ç
93 À­Ç½¾å¤Î¥á¥ê¥Ã¥È¤òÆÀ¤é¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
94 Î㤨¤Ð¡¢ÆÃÄê¤Î¥×¥í¥»¥¹¤ò°ì¤Ä¤Î CPU ¤Ë³ç¤êÉÕ¤±
95 (¤¹¤Ê¤ï¤Á¡¢¤½¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤ò°ì¤Ä¤Î CPU ¤ËÀßÄꤷ)¡¢
96 ¾¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤«¤é¤½¤Î CPU ¤ò½ü³°¤¹¤ë¤³¤È¤Ç¡¢
97 ³Î¼Â¤Ë¤½¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô®ÅÙ¤òºÇÂç¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
98 ¤Þ¤¿¡¢¤¢¤ë¥×¥í¥»¥¹¤Î¼Â¹Ô¤ò°ì¤Ä¤Î CPU ¤Ë¸ÂÄꤹ¤ë¤³¤È¤Ç¡¢
99 °ì¤Ä¤Î CPU ¤Ç¤Î¼Â¹Ô¤òÄä»ß¤·¤Æ¤«¤éÊ̤ΠCPU ¤Ç¼Â¹Ô¤òºÆ³«¤¹¤ë¤È¤­¤ËȯÀ¸¤¹¤ë
100 ¥­¥ã¥Ã¥·¥å̵¸ú²½ (cache invalidation) ¤Ë¤è¤ëÀ­Ç½Ì̤ÎÎô²½¤òÈò¤±¤ë¤³¤È¤â¤Ç¤­¤ë¡£
101
102 .\"O A CPU affinity mask is represented by the
103 .\"O .I cpu_set_t
104 .\"O structure, a "CPU set", pointed to by
105 .\"O .IR mask .
106 CPU affinity ¥Þ¥¹¥¯¤Ï¡ÖCPU ¤Î½¸¹ç¡×¤òɽ¤¹
107 .I cpu_set_t
108 ¹½Â¤ÂΤÇɽ¸½¤µ¤ì¡¢
109 .I cpu_set_t
110 ¤Ø¤Î¥Ý¥¤¥ó¥¿
111 .I mask
112 ¤Ç»ØÄꤵ¤ì¤ë¡£
113 .\"O A set of macros for manipulating CPU sets is described in
114 .\"O .BR CPU_SET (3).
115 CPU ½¸¹ç¤òÁàºî¤¹¤ë¤¿¤á¤Î¥Þ¥¯¥í·²¤Ë¤Ä¤¤¤Æ¤Ï
116 .BR CPU_SET (3)
117 ¤Çµ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£
118
119 .\"O .BR sched_setaffinity ()
120 .\"O sets the CPU affinity mask of the process whose ID is
121 .\"O .I pid
122 .\"O to the value specified by
123 .\"O .IR mask .
124 .BR sched_setaffinity ()
125 ¤Ï¡¢¥×¥í¥»¥¹ID ¤¬
126 .I pid
127 ¤Î¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤ò
128 .I mask
129 ¤Ç»ØÄꤵ¤ì¤¿ÃͤËÀßÄꤹ¤ë¡£
130 .\"O If
131 .\"O .I pid
132 .\"O is zero, then the calling process is used.
133 .\"O The argument
134 .\"O .I cpusetsize
135 .\"O is the length (in bytes) of the data pointed to by
136 .\"O .IR mask .
137 .I pid
138 ¤¬ 0 ¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬»È¤ï¤ì¤ë¡£
139 .I cpusetsize
140 °ú¤­¿ô¤Ë¤Ï
141 .I mask
142 ¤¬»Ø¤¹¥Ç¡¼¥¿¤ÎŤµ (¥Ð¥¤¥Èñ°Ì) ¤Ç¤¢¤ë¡£
143 .\"O Normally this argument would be specified as
144 .\"O .IR "sizeof(cpu_set_t)" .
145 Ä̾ï¤Ï¡¢¤³¤Î°ú¤­¿ô¤Ë¤Ï
146 .I "sizeof(cpu_set_t)"
147 ¤ò»ØÄꤹ¤ì¤Ð¤è¤¤¡£
148
149 .\"O If the process specified by
150 .\"O .I pid
151 .\"O is not currently running on one of the CPUs specified in
152 .\"O .IR mask ,
153 .\"O then that process is migrated to one of the CPUs specified in
154 .\"O .IR mask .
155 .I pid
156 ¤Ç»ØÄꤵ¤ì¤¿¥×¥í¥»¥¹¤¬
157 .I mask
158 ¤Ç»ØÄꤵ¤ì¤¿ CPU ¤Î¤¤¤º¤ì¤«¤Ç¸½ºß¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
159 ¤½¤Î¥×¥í¥»¥¹¤Ï
160 .I mask
161 ¤Ç»ØÄꤵ¤ì¤¿ CPU ¤Î¤¤¤º¤ì¤«¤Ë°ÜÆ°¤µ¤ì¤ë¡£
162
163 .\"O .BR sched_getaffinity ()
164 .\"O writes the affinity mask of the process whose ID is
165 .\"O .I pid
166 .\"O into the
167 .\"O .I cpu_set_t
168 .\"O structure pointed to by
169 .\"O .IR mask .
170 .\"O The
171 .\"O .I cpusetsize
172 .\"O argument specifies the size (in bytes) of
173 .\"O .IR mask .
174 .BR sched_getaffinity ()
175 ¤Ï¡¢
176 ¥×¥í¥»¥¹ID ¤¬
177 .I pid
178 ¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤ò
179 .I mask
180 ¤¬»Ø¤¹
181 .I cpu_set_t
182 ¹½Â¤ÂΤ˽ñ¤­¹þ¤à¡£
183 .I cpusetsize
184 °ú¤­¿ô¤Ë¤Ï
185 .I mask
186 ¤Î (¥Ð¥¤¥Èñ°Ì¤Î) Â礭¤µ¤ò»ØÄꤹ¤ë¡£
187
188 ´Ø¿ô
189 .BR sched_getaffinity ()
190 ¤ÏŤµ
191 .I len
192 ¤Î¥Ý¥¤¥ó¥¿
193 .I mask
194 ¤Ë¥×¥í¥»¥¹
195 .I pid
196 ¤Î affinity ¥Þ¥¹¥¯¤ò½ñ¤­¹þ¤à¡£
197 .\"O If
198 .\"O .I pid
199 .\"O is zero, then the mask of the calling process is returned.
200 .I pid
201 ¤¬ 0 ¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¹¥¯¤¬ÊÖ¤µ¤ì¤ë¡£
202 .\"O .SH "RETURN VALUE"
203 .SH ÊÖ¤êÃÍ
204 .\"O On success,
205 .\"O .BR sched_setaffinity ()
206 .\"O and
207 .\"O .BR sched_getaffinity ()
208 .\"O return 0.
209 À®¸ù¤·¤¿¾ì¹ç¡¢
210 .BR sched_setaffinity ()
211 ¤È
212 .BR sched_getaffinity ()
213 ¤Ï 0 ¤òÊÖ¤¹¡£
214 .\"O On error, \-1 is returned, and
215 .\"O .I errno
216 .\"O is set appropriately.
217 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
218 .I errno
219 ¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
220 .\"O .SH ERRORS
221 .SH ¥¨¥é¡¼
222 .TP
223 .B EFAULT
224 .\"O A supplied memory address was invalid.
225 »ØÄꤵ¤ì¤¿¥á¥â¥êÈÖÃϤ¬ÉÔÀµ¤Ç¤¢¤ë¡£
226 .TP
227 .B EINVAL
228 .\"O The affinity bit mask
229 .\"O .I mask
230 .\"O contains no processors that are currently physically on the system
231 .\"O and permitted to the process according to any restrictions that
232 .\"O may be imposed by the "cpuset" mechanism described in
233 .\"O .BR cpuset (7).
234 ¥·¥¹¥Æ¥à¾å¤Ë¸½ºß¼ÂºÝ¤Ë¸ºß¤·¡¢¤«¤Ä
235 "cpuset" µ¡¹½¤¬²Ý¤¹À©¸Â¤Ë¤ª¤¤¤Æ¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æµö²Ä¤µ¤ì¤Æ¤¤¤ë
236 ¥×¥í¥»¥Ã¥µ¤¬¡¢
237 affinity ¥Ó¥Ã¥È¥Þ¥¹¥¯
238 .I mask
239 ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
240 "cpuset" µ¡¹½¤Ë¤Ä¤¤¤Æ¤Ï
241 .BR cpuset (7)
242 ¤ò»²¾È¡£
243 .TP
244 .B EINVAL
245 .\"O .RB ( sched_getaffinity ()
246 .\"O and, in kernels before 2.6.9,
247 .\"O .BR sched_setaffinity ())
248 .\"O .I cpusetsize
249 .\"O is smaller than the size of the affinity mask used by the kernel.
250 .RB ( sched_getaffinity ()
251 ¤È¡¢¥«¡¼¥Í¥ë 2.6.9 °ÊÁ°¤Î
252 .BR sched_setaffinity ())
253 .I cpusetsize
254 ¤¬¥«¡¼¥Í¥ë¤Ç»È¤ï¤ì¤Æ¤¤¤ë affinity ¥Þ¥¹¥¯¤Î¥µ¥¤¥º¤è¤ê¾®¤µ¤¤¡£
255 .TP
256 .B EPERM
257 .\"O .RB ( sched_setaffinity ())
258 .\"O The calling process does not have appropriate privileges.
259 .\"O The caller needs an effective user ID equal to the real user ID
260 .\"O or effective user ID of the process identified by
261 .\"O .IR pid ,
262 .\"O or it must possess the
263 .\"O .B CAP_SYS_NICE
264 .\"O capability.
265 .RB ( sched_setaffinity ())
266 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËŬÀÚ¤ÊÆø¢¤¬¤Ê¤«¤Ã¤¿¡£
267 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢¼Â¸ú¥æ¡¼¥¶ ID ¤¬
268 .I pid
269 ¤Ç¼±Ê̤µ¤ì¤ë¥×¥í¥»¥¹¤Î¼Â¥æ¡¼¥¶ ID ¤Þ¤¿¤Ï¼Â¸ú¥æ¡¼¥¶ ID ¤ÈƱ¤¸¤Ç¤¢¤ë¤«¡¢
270 .B CAP_SYS_NICE
271 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
272 .TP
273 .B ESRCH
274 .\"O The process whose ID is \fIpid\fP could not be found.
275 ¥×¥í¥»¥¹ ID \fIpid\fP ¤Î¥×¥í¥»¥¹¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
276 .\"O .SH VERSIONS
277 .SH ¥Ð¡¼¥¸¥ç¥ó
278 .\"O The CPU affinity system calls were introduced in Linux kernel 2.5.8.
279 CPU affinity ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux kernel 2.5.8 ¤ÇƳÆþ¤µ¤ì¤¿¡£
280 .\"O The system call wrappers were introduced in glibc 2.3.
281 .\"O Initially, the glibc interfaces included a
282 .\"O .I cpusetsize
283 .\"O argument, typed as
284 .\"O .IR "unsigned int" .
285 .\"O In glibc 2.3.3, the
286 .\"O .I cpusetsize
287 .\"O argument was removed, but was then restored in glibc 2.3.4, with type
288 .\"O .IR size_t .
289 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï glibc 2.3 ¤ÇƳÆþ¤µ¤ì¤¿¡£
290 ºÇ½é¤Ï¡¢glibc ¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë¤Ï
291 .I "unsigned int"
292 ·¿¤Î
293 .I cpusetsize
294 °ú¤­¿ô¤¬Æþ¤Ã¤Æ¤¤¤¿¡£
295 glibc 2.3.3 ¤Ç¤Ï
296 .I cpusetsize
297 °ú¤­¿ô¤¬ºï½ü¤µ¤ì¤¿¤¬¡¢glibc 2.3.4 ¤Ç
298 .I size_t
299 ·¿¤ÇÉü³è¤·¤¿¡£
300 .\"O .SH "CONFORMING TO"
301 .SH ½àµò
302 .\"O These system calls are Linux-specific.
303 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£
304 .\"O .SH "NOTES"
305 .SH Ãí°Õ
306 .\"O After a call to
307 .\"O .BR sched_setaffinity (),
308 .\"O the set of CPUs on which the process will actually run is
309 .\"O the intersection of the set specified in the
310 .\"O .I mask
311 .\"O argument and the set of CPUs actually present on the system.
312 .BR sched_setaffinity ()
313 ¤ò¸Æ¤Ó½Ð¤·¤¿¸å¤Ï¡¢¥×¥í¥»¥¹¤¬¼ÂºÝ¤Ë¼Â¹Ô¤µ¤ì¤ë CPU ¤Î½¸¹ç¤Ï¡¢
314 .I mask
315 °ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿½¸¹ç¤È¡¢¥·¥¹¥Æ¥à¾å¤Ë¼ÂºÝ¤Ë¸ºß¤¹¤ë CPU ¤Î½¸¹ç¤Î
316 ¶¦Ä̽¸¹ç (AND) ¤È¤Ê¤ë¡£
317 .\"O The system may further restrict the set of CPUs on which the process
318 .\"O runs if the "cpuset" mechanism described in
319 .\"O .BR cpuset (7)
320 .\"O is being used.
321 .\"O These restrictions on the actual set of CPUs on which the process
322 .\"O will run are silently imposed by the kernel.
323 "cpuset" µ¡¹½¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¥×¥í¥»¥¹¤¬Æ°ºî¤¹¤ë CPU ½¸¹ç
324 ¤ËÂФ·¤Æ¥·¥¹¥Æ¥à¤Ï¤µ¤é¤ËÀ©¸Â¤ò²Ã¤¨¤ë¤«¤â¤·¤ì¤Ê¤¤
325 ("cpuset" µ¡¹½¤Ë¤Ä¤¤¤Æ¤Ï
326 .BR cpuset (7)
327 ¤ò»²¾È)¡£
328 ¥×¥í¥»¥¹¤¬Æ°ºî¤¹¤ë¼ÂºÝ¤Î CPU ½¸¹ç¤ËÂФ¹¤ëÀ©¸Â¤Ï¥«¡¼¥Í¥ë¤Ë¤è¤ê
329 °ÅÌۤΤ¦¤Á¤ËŬÍѤµ¤ì¤ë¡£
330
331 .\"O .BR sched_setscheduler (2)
332 .\"O has a description of the Linux scheduling scheme.
333 .BR sched_setscheduler (2)
334 ¤Ë¤Ï Linux ¤Ë¤ª¤±¤ë¥¹¥±¥¸¥å¡¼¥ê¥ó¥°µ¡¹½¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤¬¤¢¤ë¡£
335 .PP
336 .\"O The affinity mask is actually a per-thread attribute that can be
337 .\"O adjusted independently for each of the threads in a thread group.
338 .\"O The value returned from a call to
339 .\"O .BR gettid (2)
340 .\"O can be passed in the argument
341 .\"O .IR pid .
342 ¼ÂºÝ¤Ë¤Ï affinity ¥Þ¥¹¥¯¤Ï¥¹¥ì¥Ã¥Éñ°Ì¤Î°À­¤Ç¡¢¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
343 ³Æ¥¹¥ì¥Ã¥Éñ°Ì¤ËÆÈΩ¤·¤ÆÄ´À°¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
344 .BR gettid (2)
345 ¥³¡¼¥ë¤«¤é¤ÎÊÖ¤êÃͤò¤³¤Î¥³¡¼¥ë¤Î
346 .I pid
347 °ú¤­¿ô¤È¤·¤ÆÅϤ¹¤³¤È¤¬¤Ç¤­¤ë¡£
348 .\"O Specifying
349 .\"O .I pid
350 .\"O as 0 will set the attribute for the calling thread,
351 .\"O and passing the value returned from a call to
352 .\"O .BR getpid (2)
353 .\"O will set the attribute for the main thread of the thread group.
354 .\"O (If you are using the POSIX threads API, then use
355 .\"O .BR pthread_setaffinity_np (3)
356 .\"O instead of
357 .\"O .BR sched_setaffinity ().)
358 .I pid
359 ¤Ë 0 ¤ò»ØÄꤹ¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥¹¥ì¥Ã¥É¤Î°À­¤¬ÀßÄꤵ¤ì¡¢
360 .BR getpid (2)
361 ¥³¡¼¥ë¤«¤é¤ÎÊÖ¤êÃͤò
362 .I pid
363 ¤Ë»ØÄꤹ¤ë¤È¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î¥á¥¤¥ó¥¹¥ì¥Ã¥É¤Î°À­¤¬ÀßÄꤵ¤ì¤ë
364 (POSIX ¥¹¥ì¥Ã¥É API ¤ò»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¡¢
365 .BR sched_setaffinity ()
366 ¤ÎÂå¤ï¤ê¤Ë
367 .BR pthread_setaffinity_np (3)
368 ¤ò»ÈÍѤ¹¤ë¤³¤È)¡£
369
370 .\"O A child created via
371 .\"O .BR fork (2)
372 .\"O inherits its parent's CPU affinity mask.
373 .\"O The affinity mask is preserved across an
374 .\"O .BR execve (2).
375 .BR fork (2)
376 ·Ðͳ¤ÇÀ¸À®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤ò·Ñ¾µ¤¹¤ë¡£
377 affinity ¥Þ¥¹¥¯¤Ï
378 .BR execve (2)
379 ¤ÎÁ°¸å¤ÇÊݸ¤µ¤ì¤ë¡£
380
381 .\"O This manual page describes the glibc interface for the CPU affinity calls.
382 .\"O The actual system call interface is slightly different, with the
383 .\"O .I mask
384 .\"O being typed as
385 .\"O .IR "unsigned long *" ,
386 .\"O reflecting the fact that the underlying implementation of CPU
387 .\"O sets is a simple bit mask.
388 .\"O On success, the raw
389 .\"O .BR sched_getaffinity ()
390 .\"O system call returns the size (in bytes) of the
391 .\"O .I cpumask_t
392 .\"O data type that is used internally by the kernel to
393 .\"O represent the CPU set bit mask.
394 ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ç¤Ï CPU affinity ¥³¡¼¥ë¤Î glibc ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò
395 ÀâÌÀ¤·¤Æ¤¤¤ë¡£¼ÂºÝ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï¾¯¤·°ã¤Ã¤Æ¤ª¤ê¡¢
396 ¼ÂºÝ¤Î¼ÂÁõ¤Ç¤Ï CPU ½¸¹ç¤Ï´Êñ¤Ê¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¤¢¤ë¤È¤¤¤¦¼Â¾õ¤òÈ¿±Ç¤·¡¢
397 .I mask
398 ¤Î·¿¤¬
399 .IR "unsigned long *"
400 ¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
401 À®¸ù»þ¤Ë¤Ï¡¢À¸¤Î
402 .BR sched_getaffinity ()
403 ¥·¥¹¥Æ¥à¥³¡¼¥ë¼«¿È¤Ï
404 .I cpumask_t
405 ¥Ç¡¼¥¿·¿¤Î (¥Ð¥¤¥Èñ°Ì¤Î) Â礭¤µ¤òÊÖ¤¹¡£
406 .I cpumask_t
407 ¤Ï¥«¡¼¥Í¥ëÆâÉô¤Ç CPU ½¸¹ç¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤òɽ¸½¤¹¤ë¤Î¤Ë
408 »È¤ï¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿·¿¤Ç¤¢¤ë¡£
409 .\"O .SH "SEE ALSO"
410 .SH ´ØÏ¢¹àÌÜ
411 .BR clone (2),
412 .BR getcpu (2),
413 .BR getpriority (2),
414 .BR gettid (2),
415 .BR nice (2),
416 .BR sched_get_priority_max (2),
417 .BR sched_get_priority_min (2),
418 .BR sched_getscheduler (2),
419 .BR sched_setscheduler (2),
420 .BR setpriority (2),
421 .BR CPU_SET (3),
422 .BR pthread_setaffinity_np (3),
423 .BR sched_getcpu (3),
424 .BR capabilities (7),
425 .BR cpuset (7)