OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / 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 2008-11-14 "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 .B #define _GNU_SOURCE
60 .B #include <sched.h>
61 .sp
62 .BI "int sched_setaffinity(pid_t " pid ", size_t " cpusetsize ,
63 .BI "                      cpu_set_t *" mask );
64 .sp
65 .BI "int sched_getaffinity(pid_t " pid ", size_t " cpusetsize ,
66 .BI "                      cpu_set_t *" mask );
67 .fi
68 .\"O .SH DESCRIPTION
69 .SH ÀâÌÀ
70 .\"Osato:
71 .\"Osato: Kernel ¥É¥­¥å¥á¥ó¥È IRQ-affinity.txt ¤ÎÌõ¤Ç¤Ï¡¢
72 .\"Osato: "affinity" ¤Ï¡Ö¥¢¥Õ¥£¥Ë¥Æ¥£¡×¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢
73 .\"Osato: ¤³¤³¤Ë°ì²ó¤À¤±Ìõ¸ì (¿ÆÏÂÅÙ) ¤òÆþ¤ì¤Æ¤ª¤¯¤À¤±¤Ç¡¢
74 .\"Osato: ÆäËÌõ¤µ¤Ê¤¤¤³¤È¤Ë¤·¤è¤¦¤È»×¤¤¤Þ¤¹¡£
75 .\"Osato:
76 .\"O A process's CPU affinity mask determines the set of CPUs on which
77 .\"O it is eligible to run.
78 .\"O On a multiprocessor system, setting the CPU affinity mask
79 .\"O can be used to obtain performance benefits.
80 .\"O For example,
81 .\"O by dedicating one CPU to a particular process
82 .\"O (i.e., setting the affinity mask of that process to specify a single CPU,
83 .\"O and setting the affinity mask of all other processes to exclude that CPU),
84 .\"O it is possible to ensure maximum execution speed for that process.
85 .\"O Restricting a process to run on a single CPU also avoids
86 .\"O the performance cost caused by the cache invalidation that occurs
87 .\"O when a process ceases to execute on one CPU and then
88 .\"O recommences execution on a different CPU.
89 ¥×¥í¥»¥¹¤Î CPU affinity (¿ÆÏÂÅÙ) ¥Þ¥¹¥¯¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤¬
90 ¼Â¹Ô¤òµö²Ä¤µ¤ì¤Æ¤¤¤ë CPU ¤Î½¸¹ç¤ò·èÄꤹ¤ë¡£
91 ¥Þ¥ë¥Á¥×¥í¥»¥Ã¥µ¡¦¥·¥¹¥Æ¥à¤Ç¤Ï¡¢CPU affinity ¥Þ¥¹¥¯¤òÀßÄꤹ¤ë¤³¤È¤Ç
92 À­Ç½¾å¤Î¥á¥ê¥Ã¥È¤òÆÀ¤é¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
93 Î㤨¤Ð¡¢ÆÃÄê¤Î¥×¥í¥»¥¹¤ò°ì¤Ä¤Î CPU ¤Ë³ç¤êÉÕ¤±
94 (¤¹¤Ê¤ï¤Á¡¢¤½¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤ò°ì¤Ä¤Î CPU ¤ËÀßÄꤷ)¡¢
95 ¾¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤«¤é¤½¤Î CPU ¤ò½ü³°¤¹¤ë¤³¤È¤Ç¡¢
96 ³Î¼Â¤Ë¤½¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô®ÅÙ¤òºÇÂç¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
97 ¤Þ¤¿¡¢¤¢¤ë¥×¥í¥»¥¹¤Î¼Â¹Ô¤ò°ì¤Ä¤Î CPU ¤Ë¸ÂÄꤹ¤ë¤³¤È¤Ç¡¢
98 °ì¤Ä¤Î CPU ¤Ç¤Î¼Â¹Ô¤òÄä»ß¤·¤Æ¤«¤éÊ̤ΠCPU ¤Ç¼Â¹Ô¤òºÆ³«¤¹¤ë¤È¤­¤ËȯÀ¸¤¹¤ë
99 ¥­¥ã¥Ã¥·¥å̵¸ú²½ (cache invalidation) ¤Ë¤è¤ëÀ­Ç½Ì̤ÎÎô²½¤òÈò¤±¤ë¤³¤È¤â¤Ç¤­¤ë¡£
100
101 .\"O A CPU affinity mask is represented by the
102 .\"O .I cpu_set_t
103 .\"O structure, a "CPU set", pointed to by
104 .\"O .IR mask .
105 CPU affinity ¥Þ¥¹¥¯¤Ï¡ÖCPU ¤Î½¸¹ç¡×¤òɽ¤¹
106 .I cpu_set_t
107 ¹½Â¤ÂΤÇɽ¸½¤µ¤ì¡¢
108 .I cpu_set_t
109 ¤Ø¤Î¥Ý¥¤¥ó¥¿
110 .I mask
111 ¤Ç»ØÄꤵ¤ì¤ë¡£
112 .\"O A set of macros for manipulating CPU sets is described in
113 .\"O .BR CPU_SET (3).
114 CPU ½¸¹ç¤òÁàºî¤¹¤ë¤¿¤á¤Î¥Þ¥¯¥í·²¤Ë¤Ä¤¤¤Æ¤Ï
115 .BR CPU_SET (3)
116 ¤Çµ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£
117
118 .\"O .BR sched_setaffinity ()
119 .\"O sets the CPU affinity mask of the process whose ID is
120 .\"O .I pid
121 .\"O to the value specified by
122 .\"O .IR mask .
123 .BR sched_setaffinity ()
124 ¤Ï¡¢¥×¥í¥»¥¹ID ¤¬
125 .I pid
126 ¤Î¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤ò
127 .I mask
128 ¤Ç»ØÄꤵ¤ì¤¿ÃͤËÀßÄꤹ¤ë¡£
129 .\"O If
130 .\"O .I pid
131 .\"O is zero, then the calling process is used.
132 .\"O The argument
133 .\"O .I cpusetsize
134 .\"O is the length (in bytes) of the data pointed to by
135 .\"O .IR mask .
136 .I pid
137 ¤¬ 0 ¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬»È¤ï¤ì¤ë¡£
138 .I cpusetsize
139 °ú¤­¿ô¤Ë¤Ï
140 .I mask
141 ¤¬»Ø¤¹¥Ç¡¼¥¿¤ÎŤµ (¥Ð¥¤¥Èñ°Ì) ¤Ç¤¢¤ë¡£
142 .\"O Normally this argument would be specified as
143 .\"O .IR "sizeof(cpu_set_t)" .
144 Ä̾ï¤Ï¡¢¤³¤Î°ú¤­¿ô¤Ë¤Ï
145 .I "sizeof(cpu_set_t)"
146 ¤ò»ØÄꤹ¤ì¤Ð¤è¤¤¡£
147
148 .\"O If the process specified by
149 .\"O .I pid
150 .\"O is not currently running on one of the CPUs specified in
151 .\"O .IR mask ,
152 .\"O then that process is migrated to one of the CPUs specified in
153 .\"O .IR mask .
154 .I pid
155 ¤Ç»ØÄꤵ¤ì¤¿¥×¥í¥»¥¹¤¬
156 .I mask
157 ¤Ç»ØÄꤵ¤ì¤¿ CPU ¤Î¤¤¤º¤ì¤«¤Ç¸½ºß¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
158 ¤½¤Î¥×¥í¥»¥¹¤Ï
159 .I mask
160 ¤Ç»ØÄꤵ¤ì¤¿ CPU ¤Î¤¤¤º¤ì¤«¤Ë°ÜÆ°¤µ¤ì¤ë¡£
161
162 .\"O .BR sched_getaffinity ()
163 .\"O writes the affinity mask of the process whose ID is
164 .\"O .I pid
165 .\"O into the
166 .\"O .I cpu_set_t
167 .\"O structure pointed to by
168 .\"O .IR mask .
169 .\"O The
170 .\"O .I cpusetsize
171 .\"O argument specifies the size (in bytes) of
172 .\"O .IR mask .
173 .BR sched_getaffinity ()
174 ¤Ï¡¢
175 ¥×¥í¥»¥¹ID ¤¬
176 .I pid
177 ¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤ò
178 .I mask
179 ¤¬»Ø¤¹
180 .I cpu_set_t
181 ¹½Â¤ÂΤ˽ñ¤­¹þ¤à¡£
182 .I cpusetsize
183 °ú¤­¿ô¤Ë¤Ï
184 .I mask
185 ¤Î (¥Ð¥¤¥Èñ°Ì¤Î) Â礭¤µ¤ò»ØÄꤹ¤ë¡£
186
187 ´Ø¿ô
188 .BR sched_getaffinity ()
189 ¤ÏŤµ
190 .I len
191 ¤Î¥Ý¥¤¥ó¥¿
192 .I mask
193 ¤Ë¥×¥í¥»¥¹
194 .I pid
195 ¤Î affinity ¥Þ¥¹¥¯¤ò½ñ¤­¹þ¤à¡£
196 .\"O If
197 .\"O .I pid
198 .\"O is zero, then the mask of the calling process is returned.
199 .I pid
200 ¤¬ 0 ¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¹¥¯¤¬ÊÖ¤µ¤ì¤ë¡£
201 .\"O .SH "RETURN VALUE"
202 .SH ÊÖ¤êÃÍ
203 .\"O On success,
204 .\"O .BR sched_setaffinity ()
205 .\"O and
206 .\"O .BR sched_getaffinity ()
207 .\"O return 0.
208 À®¸ù¤·¤¿¾ì¹ç¡¢
209 .BR sched_setaffinity ()
210 ¤È
211 .BR sched_getaffinity ()
212 ¤Ï 0 ¤òÊÖ¤¹¡£
213 .\"O On error, \-1 is returned, and
214 .\"O .I errno
215 .\"O is set appropriately.
216 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
217 .I errno
218 ¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
219 .\"O .SH ERRORS
220 .SH ¥¨¥é¡¼
221 .TP
222 .B EFAULT
223 .\"O A supplied memory address was invalid.
224 »ØÄꤵ¤ì¤¿¥á¥â¥êÈÖÃϤ¬ÉÔÀµ¤Ç¤¢¤ë¡£
225 .TP
226 .B EINVAL
227 .\"O The affinity bit mask
228 .\"O .I mask
229 .\"O contains no processors that are currently physically on the system
230 .\"O and permitted to the process according to any restrictions that
231 .\"O may be imposed by the "cpuset" mechanism described in
232 .\"O .BR cpuset (7).
233 ¥·¥¹¥Æ¥à¾å¤Ë¸½ºß¼ÂºÝ¤Ë¸ºß¤·¡¢¤«¤Ä
234 "cpuset" µ¡¹½¤¬²Ý¤¹À©¸Â¤Ë¤ª¤¤¤Æ¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æµö²Ä¤µ¤ì¤Æ¤¤¤ë
235 ¥×¥í¥»¥Ã¥µ¤¬¡¢
236 affinity ¥Ó¥Ã¥È¥Þ¥¹¥¯
237 .I mask
238 ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
239 "cpuset" µ¡¹½¤Ë¤Ä¤¤¤Æ¤Ï
240 .BR cpuset (7)
241 ¤ò»²¾È¡£
242 .TP
243 .B EINVAL
244 .\"O .RB ( sched_getaffinity ()
245 .\"O and, in kernels before 2.6.9,
246 .\"O .BR sched_setaffinity ())
247 .\"O .I cpusetsize
248 .\"O is smaller than the size of the affinity mask used by the kernel.
249 .RB ( sched_getaffinity ()
250 ¤È¡¢¥«¡¼¥Í¥ë 2.6.9 °ÊÁ°¤Î
251 .BR sched_setaffinity ())
252 .I cpusetsize
253 ¤¬¥«¡¼¥Í¥ë¤Ç»È¤ï¤ì¤Æ¤¤¤ë affinity ¥Þ¥¹¥¯¤Î¥µ¥¤¥º¤è¤ê¾®¤µ¤¤¡£
254 .TP
255 .B EPERM
256 .\"O .RB ( sched_setaffinity ())
257 .\"O The calling process does not have appropriate privileges.
258 .\"O The caller needs an effective user ID equal to the user ID
259 .\"O or effective user ID of the process identified by
260 .\"O .IR pid ,
261 .\"O or it must possess the
262 .\"O .B CAP_SYS_NICE
263 .\"O capability.
264 .RB ( sched_setaffinity ())
265 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËŬÀÚ¤ÊÆø¢¤¬¤Ê¤«¤Ã¤¿¡£
266 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢¼Â¸ú¥æ¡¼¥¶ ID ¤¬
267 .I pid
268 ¤Ç¼±Ê̤µ¤ì¤ë¥×¥í¥»¥¹¤Î¥æ¡¼¥¶ ID ¤Þ¤¿¤Ï¼Â¸ú¥æ¡¼¥¶ ID ¤ÈƱ¤¸¤Ç¤¢¤ë¤«¡¢
269 .B CAP_SYS_NICE
270 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
271 .TP
272 .B ESRCH
273 .\"O The process whose ID is \fIpid\fP could not be found.
274 ¥×¥í¥»¥¹ ID \fIpid\fP ¤Î¥×¥í¥»¥¹¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
275 .\"O .SH VERSIONS
276 .SH ¥Ð¡¼¥¸¥ç¥ó
277 .\"O The CPU affinity system calls were introduced in Linux kernel 2.5.8.
278 CPU affinity ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux kernel 2.5.8 ¤ÇƳÆþ¤µ¤ì¤¿¡£
279 .\"O The system call wrappers were introduced in glibc 2.3.
280 .\"O Initially, the glibc interfaces included a
281 .\"O .I cpusetsize
282 .\"O argument, typed as
283 .\"O .IR "unsigned int" .
284 .\"O In glibc 2.3.3, the
285 .\"O .I cpusetsize
286 .\"O argument was removed, but was then restored in glibc 2.3.4, with type
287 .\"O .IR size_t .
288 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï glibc 2.3 ¤ÇƳÆþ¤µ¤ì¤¿¡£
289 ºÇ½é¤Ï¡¢glibc ¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë¤Ï
290 .I "unsigned int"
291 ·¿¤Î
292 .I cpusetsize
293 °ú¤­¿ô¤¬Æþ¤Ã¤Æ¤¤¤¿¡£
294 glibc 2.3.3 ¤Ç¤Ï
295 .I cpusetsize
296 °ú¤­¿ô¤¬ºï½ü¤µ¤ì¤¿¤¬¡¢glibc 2.3.4 ¤Ç
297 .I size_t
298 ·¿¤ÇÉü³è¤·¤¿¡£
299 .\"O .SH "CONFORMING TO"
300 .SH ½àµò
301 .\"O These system calls are Linux-specific.
302 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£
303 .\"O .SH "NOTES"
304 .SH Ãí°Õ
305 .\"O After a call to
306 .\"O .BR sched_setaffinity (),
307 .\"O the set of CPUs on which the process will actually run is
308 .\"O the intersection of the set specified in the
309 .\"O .I mask
310 .\"O argument and the set of CPUs actually present on the system.
311 .BR sched_setaffinity ()
312 ¤ò¸Æ¤Ó½Ð¤·¤¿¸å¤Ï¡¢¥×¥í¥»¥¹¤¬¼ÂºÝ¤Ë¼Â¹Ô¤µ¤ì¤ë CPU ¤Î½¸¹ç¤Ï¡¢
313 .I mask
314 °ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿½¸¹ç¤È¡¢¥·¥¹¥Æ¥à¾å¤Ë¼ÂºÝ¤Ë¸ºß¤¹¤ë CPU ¤Î½¸¹ç¤Î
315 ¶¦Ä̽¸¹ç (AND) ¤È¤Ê¤ë¡£
316 .\"O The system may further restrict the set of CPUs on which the process
317 .\"O runs if the "cpuset" mechanism described in
318 .\"O .BR cpuset (7)
319 .\"O is being used.
320 .\"O These restrictions on the actual set of CPUs on which the process
321 .\"O will run are silently imposed by the kernel.
322 "cpuset" µ¡¹½¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¥×¥í¥»¥¹¤¬Æ°ºî¤¹¤ë CPU ½¸¹ç
323 ¤ËÂФ·¤Æ¥·¥¹¥Æ¥à¤Ï¤µ¤é¤ËÀ©¸Â¤ò²Ã¤¨¤ë¤«¤â¤·¤ì¤Ê¤¤
324 ("cpuset" µ¡¹½¤Ë¤Ä¤¤¤Æ¤Ï
325 .BR cpuset (7)
326 ¤ò»²¾È)¡£
327 ¥×¥í¥»¥¹¤¬Æ°ºî¤¹¤ë¼ÂºÝ¤Î CPU ½¸¹ç¤ËÂФ¹¤ëÀ©¸Â¤Ï¥«¡¼¥Í¥ë¤Ë¤è¤ê
328 °ÅÌۤΤ¦¤Á¤ËŬÍѤµ¤ì¤ë¡£
329
330 .\"O .BR sched_setscheduler (2)
331 .\"O has a description of the Linux scheduling scheme.
332 .BR sched_setscheduler (2)
333 ¤Ë¤Ï Linux ¤Ë¤ª¤±¤ë¥¹¥±¥¸¥å¡¼¥ê¥ó¥°µ¡¹½¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤¬¤¢¤ë¡£
334 .PP
335 .\"O The affinity mask is actually a per-thread attribute that can be
336 .\"O adjusted independently for each of the threads in a thread group.
337 .\"O The value returned from a call to
338 .\"O .BR gettid (2)
339 .\"O can be passed in the argument
340 .\"O .IR pid .
341 ¼ÂºÝ¤Ë¤Ï affinity ¥Þ¥¹¥¯¤Ï¥¹¥ì¥Ã¥Éñ°Ì¤Î°À­¤Ç¡¢¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
342 ³Æ¥¹¥ì¥Ã¥Éñ°Ì¤ËÆÈΩ¤·¤ÆÄ´À°¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
343 .BR gettid (2)
344 ¥³¡¼¥ë¤«¤é¤ÎÊÖ¤êÃͤò¤³¤Î¥³¡¼¥ë¤Î
345 .I pid
346 °ú¤­¿ô¤È¤·¤ÆÅϤ¹¤³¤È¤¬¤Ç¤­¤ë¡£
347 .\"O Specifying
348 .\"O .I pid
349 .\"O as 0 will set the attribute for the calling thread,
350 .\"O and passing the value returned from a call to
351 .\"O .BR getpid (2)
352 .\"O will set the attribute for the main thread of the thread group.
353 .\"O (If you are using the POSIX threads API, then use
354 .\"O .BR pthread_setaffinity_np (3)
355 .\"O instead of
356 .\"O .BR sched_setaffinity ().)
357 .I pid
358 ¤Ë 0 ¤ò»ØÄꤹ¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥¹¥ì¥Ã¥É¤Î°À­¤¬ÀßÄꤵ¤ì¡¢
359 .BR getpid (2)
360 ¥³¡¼¥ë¤«¤é¤ÎÊÖ¤êÃͤò
361 .I pid
362 ¤Ë»ØÄꤹ¤ë¤È¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î¥á¥¤¥ó¥¹¥ì¥Ã¥É¤Î°À­¤¬ÀßÄꤵ¤ì¤ë
363 (POSIX ¥¹¥ì¥Ã¥É API ¤ò»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¡¢
364 .BR sched_setaffinity ()
365 ¤ÎÂå¤ï¤ê¤Ë
366 .BR pthread_setaffinity_np (3)
367 ¤ò»ÈÍѤ¹¤ë¤³¤È)¡£
368
369 .\"O A child created via
370 .\"O .BR fork (2)
371 .\"O inherits its parent's CPU affinity mask.
372 .\"O The affinity mask is preserved across an
373 .\"O .BR execve (2).
374 .BR fork (2)
375 ·Ðͳ¤ÇÀ¸À®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤ò·Ñ¾µ¤¹¤ë¡£
376 affinity ¥Þ¥¹¥¯¤Ï
377 .BR execve (2)
378 ¤ÎÁ°¸å¤ÇÊݸ¤µ¤ì¤ë¡£
379
380 .\"O This manual page describes the glibc interface for the CPU affinity calls.
381 .\"O The actual system call interface is slightly different, with the
382 .\"O .I mask
383 .\"O being typed as
384 .\"O .IR "unsigned long *" ,
385 .\"O reflecting the fact that the underlying implementation of CPU
386 .\"O sets is a simple bit mask.
387 .\"O On success, the raw
388 .\"O .BR sched_getaffinity ()
389 .\"O system call returns the size (in bytes) of the
390 .\"O .I cpumask_t
391 .\"O data type that is used internally by the kernel to
392 .\"O represent the CPU set bit mask.
393 ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ç¤Ï CPU affinity ¥³¡¼¥ë¤Î glibc ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò
394 ÀâÌÀ¤·¤Æ¤¤¤ë¡£¼ÂºÝ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï¾¯¤·°ã¤Ã¤Æ¤ª¤ê¡¢
395 ¼ÂºÝ¤Î¼ÂÁõ¤Ç¤Ï CPU ½¸¹ç¤Ï´Êñ¤Ê¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¤¢¤ë¤È¤¤¤¦¼Â¾õ¤òÈ¿±Ç¤·¡¢
396 .I mask
397 ¤Î·¿¤¬
398 .IR "unsigned long *"
399 ¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
400 À®¸ù»þ¤Ë¤Ï¡¢À¸¤Î
401 .BR sched_getaffinity ()
402 ¥·¥¹¥Æ¥à¥³¡¼¥ë¼«¿È¤Ï
403 .I cpumask_t
404 ¥Ç¡¼¥¿·¿¤Î (¥Ð¥¤¥Èñ°Ì¤Î) Â礭¤µ¤òÊÖ¤¹¡£
405 .I cpumask_t
406 ¤Ï¥«¡¼¥Í¥ëÆâÉô¤Ç CPU ½¸¹ç¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤òɽ¸½¤¹¤ë¤Î¤Ë
407 »È¤ï¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿·¿¤Ç¤¢¤ë¡£
408 .\"O .SH "SEE ALSO"
409 .SH ´ØÏ¢¹àÌÜ
410 .BR clone (2),
411 .BR getcpu (2),
412 .BR getpriority (2),
413 .BR gettid (2),
414 .BR nice (2),
415 .BR sched_get_priority_max (2),
416 .BR sched_get_priority_min (2),
417 .BR sched_getscheduler (2),
418 .BR sched_setscheduler (2),
419 .BR setpriority (2),
420 .BR pthread_setaffinity_np (3),
421 .BR CPU_SET (3),
422 .BR sched_getcpu (3),
423 .BR capabilities (7),
424 .BR cpuset (7)