File: sched_setaffinity.2

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (252 lines) | stat: -rw-r--r-- 7,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
.\" man2/sched_setaffinity.2 - sched_setaffinity and sched_getaffinity man page
.\"
.\" Copyright (C) 2002 Robert Love
.\" and Copyright (C) 2006 Michael Kerrisk
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.\" 2002-11-19 Robert Love <rml@tech9.net> - initial version
.\" 2004-04-20 mtk - fixed description of return value
.\" 2004-04-22 aeb - added glibc prototype history
.\" 2005-05-03 mtk - noted that sched_setaffinity may cause thread
.\"	migration and that CPU affinity is a per-thread attribute.
.\" 2006-02-03 mtk -- Major rewrite
.\"
.\" Japanese Version Copyright (c) 2003, 2005 Yuichi SATO
.\"         all rights reserved.
.\" Translated 2003-01-23, Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified 2003-09-23, Yuichi SATO
.\" Updated & Modified 2005-01-03, Yuichi SATO
.\" Updated & Modified 2005-09-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated & Modified 2006-07-14, Akihiro MOTOKI, Catch up to LDP v2.34
.\"
.\"WORD:	affinity		
.\"WORD:	most significant bit	Ǿ̥ӥå
.\"WORD:	least significant bit	Dz̥ӥå
.\"WORD:	capability		
.\"
.TH SCHED_SETAFFINITY 2 2006-02-03 "Linux" "Linux Programmer's Manual"
.SH ̾
sched_setaffinity, sched_getaffinity, CPU_CLR, CPU_ISSET, CPU_SET, CPU_ZERO \
\- ץ CPU affinity ޥꡦ
.SH 
.nf
.B #define _GNU_SOURCE
.B #include <sched.h>
.sp
.BI "int sched_setaffinity(pid_t " pid ", unsigned int " cpusetsize ,
.BI "                      cpu_set_t *" mask );
.sp
.BI "int sched_getaffinity(pid_t " pid ", unsigned int " cpusetsize ,
.BI "                      cpu_set_t *" mask );
.sp
.BI "void CPU_CLR(int " cpu ", cpu_set_t *" set );
.br
.BI "int CPU_ISSET(int " cpu ", cpu_set_t *" set );
.br
.BI "void CPU_SET(int " cpu ", cpu_set_t *" set );
.br
.BI "void CPU_ZERO(cpu_set_t *" set );
.fi
.SH 
ץ CPU affinity () ޥϡΥץ
¹ԤĤƤ CPU νꤹ롣
ޥץåƥǤϡCPU affinity ޥꤹ뤳Ȥ
ǽΥåȤǽ롣
㤨СΥץĤ CPU ˳դ
(ʤΥץ affinity ޥĤ CPU ꤷ)
¾ƤΥץ affinity ޥ餽 CPU 뤳Ȥǡ
μ¤ˤΥץμ¹®٤ˤ뤳ȤǤ롣
ޤץμ¹ԤĤ CPU ˸ꤹ뤳Ȥǡ
Ĥ CPU Ǥμ¹ԤߤƤ̤ CPU Ǽ¹ԤƳȤȯ
å̵ (cache invalidation) ˤǽ̤ɤȤǤ롣

CPU affinity ޥϡCPU νפɽ
.I cpu_set_t
¤Τɽ졢
.I cpu_set_t
ؤΥݥ
.I mask
ǻꤵ롣
CPU 뤿Υޥ 4 󶡤Ƥ롣
.BR CPU_ZERO ()
Ͻ򥯥ꥢ롣
.BR CPU_SET ()

.BR CPU_CLR ()
Ϥ줾ꤵ줿 CPU νؤɲ/Ԥ
.BR CPU_ISSET ()
Ϥ CPU ˴ޤޤƤ뤫γǧԤΥޥ
.BR sched_getaffinity ()
ƤӽФǻѤǤ롣
ƥˤǽ CPU 
.I cpu
 0 ˡ CPU 
.I cpu
 1 бʸƱͤǤ롣

.B CPU_SETSIZE
(1024) ϡCPU  CPU ֹκͤ 1 礭ͤ򼨤

.BR sched_setaffinity ()
ϡץID 
.I pid
Υץ CPU affinity ޥ
.I mask
ǻꤵ줿ͤꤹ롣
.I pid
 0 ξ硢ƤӽФץȤ롣
.I cpusetsize
ˤ
.I mask
ؤǡĹ (Хñ) Ǥ롣
̾ϡΰˤ
.I "sizeof(cpu_set_t)"
ꤹФ褤

.I pid
ǻꤵ줿ץ
.I mask
ǻꤵ줿 CPU Τ줫Ǹ߼¹ԤƤʤ硢
Υץ
.I mask
ǻꤵ줿 CPU Τ줫˰ư롣

.BR sched_getaffinity ()
ϡ
ץID 
.I pid
Υץ affinity ޥ
.I mask
ؤ
.I cpu_set_t
¤Τ˽񤭹ࡣ
.I cpusetsize
ˤ
.I mask
 (Хñ̤) 礭ꤹ롣

ؿ
.BR sched_getaffinity ()
Ĺ
.I len
Υݥ
.I mask
˥ץ
.I pid
 affinity ޥ񤭹ࡣ
.I pid
 0 ξ硢ƤӽФΥץΥޥ֤롣
.SH ֤
.BR sched_setaffinity ()

.BR sched_getaffinity ()
 0 ֤
顼ξ \-1 ֤
.I errno
Ŭڤꤹ롣
.SH 顼
.TP
.B EFAULT
ꤵ줿ϤǤ롣
.TP
.B EINVAL
affinity ӥåȥޥ
.I mask
˥ƥ˼ºݤ¸ߤץåбӥåȤʤ
.\" ʲϡsched_getaffinity() ƥॳľɤ
.\"  (?)  (MTK, 3 Feb 2006):
ޤϥޥĹ
.I cpusetsize
ͥǻȤƤ affinity ޥû
.TP
.B EPERM
ƤӽФΥץŬڤøʤä
.BR sched_setaffinity ()
ƤӽФץϡ¸桼 ID 
.I pid
Ǽ̤ץΥ桼 ID ޤϼ¸桼 ID ƱǤ뤫
.B CAP_SYS_NICE
ѥӥƥ (capability) ʤФʤʤ
.TP
.B ESRCH
ץ ID \fIpid\fP ΥץĤʤä
.SH С
CPU affinity ƥॳ Linux kernel 2.5.8 Ƴ줿
饤֥¦Υ󥿥ե glibc 2.3 Ƴ줿
ǽϡglibc Υ󥿥եˤ
.I cpusetsize
äƤ
glibc 2.3.3 Ǥ
.I cpusetsize
줿glibc 2.3.4 Ǹᤵ줿
.SH 
Υƥॳ Linux ͭǤ롣
.SH 
.BR sched_setscheduler (2)
ˤ Linux ˤ륹塼󥰵ˤĤƤ롣
.PP
ºݤˤ affinity ޥϥåñ̤°ǡåɥ롼פ
ƥåñ̤ΩĴ뤳ȤǤ롣
.BR gettid (2)
뤫֤ͤ򤳤Υ
.I pid
ȤϤȤǤ롣
.I pid
 0 ꤹȸߤΥåɤ°ꤵ졢
.BR getpid (2)
뤫֤ͤ
.I pid
˻ꤹȥåɥ롼פΥᥤ󥹥åɤ°ꤵ롣

.BR fork (2)
ͳ줿ҥץϿƥץ CPU affinity ޥѾ롣
affinity ޥ
.BR execve (2)
¸롣

Υޥ˥奢ڡǤ CPU affinity  glibc 󥿥ե
Ƥ롣ºݤΥƥॳ롦󥿥եϾäƤꡢ
ºݤμǤ CPU ϴñʥӥåȥޥǤȤ¾ȿǤ
.I mask
η
.IR "unsigned long *"
ȤʤäƤ롣
ˤϡ
.BR sched_getaffinity ()
ƥॳ뼫Ȥ
.I cpumask_t
ǡ (Хñ̤) 礭֤
.I cpumask_t
ϥͥ CPU ΥӥåȥޥɽΤ
ȤƤǡǤ롣
.SH Ϣ
.BR clone (2),
.BR getpriority (2),
.BR gettid (2),
.BR nice (2),
.BR sched_get_priority_max (2),
.BR sched_get_priority_min (2),
.BR sched_getscheduler (2),
.BR sched_setscheduler (2),
.BR setpriority (2),
.BR capabilities (7)