1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) Tom Bjorkholm, Markus Kuhn & David A. Wheeler 1996-1999
4 .\" and Copyright (C) 2007 Carsten Emde <Carsten.Emde@osadl.org>
5 .\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
7 .\" This is free documentation; you can redistribute it and/or
8 .\" modify it under the terms of the GNU General Public License as
9 .\" published by the Free Software Foundation; either version 2 of
10 .\" the License, or (at your option) any later version.
12 .\" The GNU General Public License's references to "object code"
13 .\" and "executables" are to be interpreted as the output of any
14 .\" document formatting or typesetting system, including
15 .\" intermediate and printed output.
17 .\" This manual is distributed in the hope that it will be useful,
18 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 .\" GNU General Public License for more details.
22 .\" You should have received a copy of the GNU General Public
23 .\" License along with this manual; if not, write to the Free
24 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
27 .\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
28 .\" First version written
29 .\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
31 .\" 1999-08-18 David A. Wheeler <dwheeler@ida.org> added Note.
32 .\" Modified, 25 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Corrected description of queue placement by sched_setparam() and
34 .\" sched_setscheduler()
35 .\" A couple of grammar clean-ups
36 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" 2005-03-23, mtk, Added description of SCHED_BATCH.
38 .\" 2007-07-10, Carsten Emde <Carsten.Emde@osadl.org>
39 .\" Add text on real-time features that are currently being
40 .\" added to the mainline kernel.
41 .\" 2008-05-07, mtk; Rewrote and restructured various parts of the page to
42 .\" improve readability.
44 .\" Worth looking at: http://rt.wiki.kernel.org/index.php
46 .\" FIXME: 2.6.32 added SCHED_RESET_ON_FORK
48 .\" Japanese Version Copyright (c) 1996 Akira Yoshiyama
49 .\" all rights reserved.
50 .\" Translated Thu Jul 11 01:42:52 JST 1996
51 .\" by Akira Yoshiyama <yosshy@jedi.seg.kobe-u.ac.jp>
52 .\" Modified Sun Nov 21 19:36:18 JST 1999
53 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
54 .\" Updated Wed Jan 1 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
55 .\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
56 .\" Updated & Modified 2005-10-10, Akihiro MOTOKI
57 .\" Updated 2006-04-16, Akihiro MOTOKI, Catch up to LDP v2.28
58 .\" Updated 2007-10-13, Akihiro MOTOKI, LDP v2.65
59 .\" Updated 2008-08-13, Akihiro MOTOKI, LDP v3.05
61 .\"WORD: privileges 特権
62 .\"WORD: resource limit リソース制限
63 .\"WORD: scheduling policy スケジューリング・ポリシー
65 .TH SCHED_SETSCHEDULER 2 2008-11-06 "Linux" "Linux Programmer's Manual"
68 .\"O sched_setscheduler, sched_getscheduler \-
69 .\"O set and get scheduling policy/parameters
70 sched_setscheduler, sched_getscheduler \-
71 スケジューリング・ポリシーとパラメータを設定/取得する
77 .BI "int sched_setscheduler(pid_t " pid ", int " policy ,
79 .BI " const struct sched_param *" param );
81 .BI "int sched_getscheduler(pid_t " pid );
83 \fBstruct sched_param {
85 int \fIsched_priority\fB;
91 .\"O .BR sched_setscheduler ()
92 .\"O sets both the scheduling policy and the associated parameters for the
93 .\"O process whose ID is specified in \fIpid\fP.
94 .\"O If \fIpid\fP equals zero, the
95 .\"O scheduling policy and parameters of the calling process will be set.
96 .\"O The interpretation of
97 .\"O the argument \fIparam\fP depends on the selected policy.
98 .\"O Currently, Linux supports the following "normal"
99 .\"O (i.e., non-real-time) scheduling policies:
100 .BR sched_setscheduler ()
101 は \fIpid\fP で指定された ID を持つプロセスのスケジューリング・ポリシーや
102 それに関連するパラメータを設定する。\fIpid\fP が 0 の場合は
103 呼び出したプロセスのスケジューリング・ポリシーとパラメータが設定される。
104 引き数 \fIparam\fP の解釈は選択されたポリシーによる。
106 以下に示す「通常」(リアルタイムでない) スケジューリング・ポリシーが
110 .\"O the standard round-robin time-sharing policy;
111 標準の、ラウンドロビンによる時分割型のスケジューリング・ポリシー。
112 .\"O .\" In the 2.6 kernel sources, SCHED_OTHER is actually called
113 .\"O .\" SCHED_NORMAL.
114 .\" 2.6 カーネルソースでは、SCHED_OTHER は実際には
115 .\" SCHED_NORMAL と呼ばれている。
118 .\"O for "batch" style execution of processes; and
124 .\"O low priority background jobs.
125 「非常に」低い優先度で動作するバックグラウンド・ジョブ用。
127 .\"O The following "real-time" policies are also supported,
128 .\"O for special time-critical applications that need precise control over
129 .\"O the way in which runnable processes are selected for execution:
130 どの実行可能プロセスを選択するかについて、より正確な制御を必要とする
131 時間の制約が厳しい特別なアプリケーション用として、
132 以下の「リアルタイム」ポリシーもサポートされている。
135 .\"O a first-in, first-out policy; and
136 ファーストイン、ファーストアウト型のポリシー。
139 .\"O a round-robin policy.
142 .\"O The semantics of each of these policies are detailed below.
143 これらのポリシーのそれぞれの動作については以下で説明する。
145 .\"O .BR sched_getscheduler ()
146 .\"O queries the scheduling policy currently applied to the process
147 .\"O identified by \fIpid\fP.
148 .\"O If \fIpid\fP equals zero, the policy of the
149 .\"O calling process will be retrieved.
150 .BR sched_getscheduler ()
151 は \fIpid\fP で識別されるプロセスに現在適用されている
152 スケジューリング・ポリシーを尋ねる。\fIpid\fP が 0 ならば、呼び出した
153 プロセス自身のスケジューリング・ポリシーが返される。
155 .\"O .SS Scheduling Policies
156 .SS スケジューリング・ポリシー (scheduling policy)
157 .\"O The scheduler is the kernel component that decides which runnable process
158 .\"O will be executed by the CPU next.
159 .\"O Each process has an associated scheduling policy and a \fIstatic\fP
160 .\"O scheduling priority, \fIsched_priority\fP; these are the settings
161 .\"O that are modified by
162 .\"O .BR sched_setscheduler ().
163 .\"O The scheduler makes it decisions based on knowledge of the scheduling
164 .\"O policy and static priority of all processes on the system.
165 スケジューラ (scheduler) とはカーネルの構成要素で、
166 次に CPU で実行される実行可能なプロセスを決定するものである。
167 各々のプロセスには、スケジューリング・ポリシーと
168 「静的」なスケジューリング優先度 \fIsched_priority\fP が対応付けられ、
170 .BR sched_setscheduler ()
172 スケジューラは、システム上の全プロセスのスケジューリング・ポリシーと
173 静的優先度に関する知識に基づいて決定を行う。
175 .\"O For processes scheduled under one of the normal scheduling policies
176 .\"O (\fBSCHED_OTHER\fP, \fBSCHED_IDLE\fP, \fBSCHED_BATCH\fP),
177 .\"O \fIsched_priority\fP is not used in scheduling
178 .\"O decisions (it must be specified as 0).
180 (\fBSCHED_OTHER\fP, \fBSCHED_IDLE\fP, \fBSCHED_BATCH\fP)
181 の下でスケジューリングされるプロセスでは、
182 \fIsched_priority\fP はスケジューリングの決定に使用されない
183 (\fIsched_priority\fP には 0 を指定しなければならない)。
185 .\"O Processes scheduled under one of the real-time policies
186 .\"O (\fBSCHED_FIFO\fP, \fBSCHED_RR\fP) have a
187 .\"O \fIsched_priority\fP value in the range 1 (low) to 99 (high).
188 .\"O (As the numbers imply, real-time processes always have higher priority
189 .\"O than normal processes.)
190 リアルタイム・スケジューリング・ポリシー (\fBSCHED_FIFO\fP, \fBSCHED_RR\fP)
192 \fIsched_priority\fP の値は 1 (最低) から 99 (最高) の範囲となる
193 (数字から分かるように、リアルタイム・プロセスは常に通常のプロセスよりも
195 .\"O Note well: POSIX.1-2001 only requires an implementation to support a
196 .\"O minimum 32 distinct priority levels for the real-time policies,
197 .\"O and some systems supply just this minimum.
198 .\"O Portable programs should use
199 .\"O .BR sched_get_priority_min (2)
201 .\"O .BR sched_get_priority_max (2)
202 .\"O to find the range of priorities supported for a particular policy.
203 ここで注意すべきなのは、POSIX.1-2001 が要求しているのは、
204 リアルタイム・ポリシーの実装において最低 32 種類の異なる優先度レベルが
205 サポートされることだけであり、いくつかのシステムではこの最低限の数の
206 優先度しか提供されていない、ということである。
208 .BR sched_get_priority_min (2)
210 .BR sched_get_priority_max (2)
211 を使って、あるポリシーがサポートする優先度の範囲を調べるべきである。
213 .\"O Conceptually, the scheduler maintains a list of runnable
214 .\"O processes for each possible \fIsched_priority\fP value.
215 .\"O In order to determine which process runs next, the scheduler looks for
216 .\"O the nonempty list with the highest static priority and selects the
217 .\"O process at the head of this list.
219 スケジューラはその \fIsched_priority\fP の値それぞれに対して
220 実行可能なプロセスのリストを管理している。
221 どのプロセスを次に実行するかを決定するために、
222 スケジューラは静的優先度の最も高い空でないリストを探して、
225 .\"O A process's scheduling policy determines
226 .\"O where it will be inserted into the list of processes
227 .\"O with equal static priority and how it will move inside this list.
228 各プロセスのスケジューリング・ポリシーは、
229 そのプロセスが同じ静的優先度を持つプロセスのリストの中のどこに挿入され、
230 このリストの中をどのように移動するかを決定する。
232 .\"O All scheduling is preemptive: if a process with a higher static
233 .\"O priority becomes ready to run, the currently running process
234 .\"O will be preempted and
235 .\"O returned to the wait list for its static priority level.
236 .\"O The scheduling policy only determines the
237 .\"O ordering within the list of runnable processes with equal static
239 全てのスケジューリングはプリエンプティブ (preemptive) である:
240 より高い優先度のプロセスが実行可能になると、現在実行中のプロセスは実行権を
241 取り上げられ (preempted)、そのプロセスの静的優先度レベルの待ちリストに
242 戻される。スケジューリング・ポリシーは同じ静的優先度を持つ実行可能な
243 プロセスのリストの中で順番のみを決定する。
244 .\"O .SS SCHED_FIFO: First In-First Out scheduling
245 .SS SCHED_FIFO: ファーストイン・ファーストアウト・スケジューリング
246 .\"O \fBSCHED_FIFO\fP can only be used with static priorities higher than
247 .\"O 0, which means that when a \fBSCHED_FIFO\fP processes becomes runnable,
248 .\"O it will always immediately preempt any currently running
249 .\"O \fBSCHED_OTHER\fP, \fBSCHED_BATCH\fP, or \fBSCHED_IDLE\fP process.
250 .\"O \fBSCHED_FIFO\fP is a simple scheduling
251 .\"O algorithm without time slicing.
252 .\"O For processes scheduled under the
253 .\"O \fBSCHED_FIFO\fP policy, the following rules apply:
254 \fBSCHED_FIFO\fP は 0 より大きな静的優先度でのみ使用できる。このポリシーでは、
255 \fBSCHED_FIFO\fP プロセスが実行可能になった場合、
256 そのポリシーが \fBSCHED_OTHER\fP、 \fBSCHED_BATCH\fP、 \fBSCHED_IDLE\fP の
257 現在実行中のプロセスは直ちに実行権を取り上げられる。
258 \fBSCHED_FIFO\fP は時分割のない単純なスケジューリング・アルゴリズムである。
259 \fBSCHED_FIFO\fP ポリシーでスケジューリングされているプロセスには以下の
262 .\"O A \fBSCHED_FIFO\fP process that has been preempted by another process of
263 .\"O higher priority will stay at the head of the list for its priority and
264 .\"O will resume execution as soon as all processes of higher priority are
266 より高い優先度の他のプロセスによって取って代わられた
267 \fBSCHED_FIFO\fP プロセスはその優先度のリストの先頭に留まり続け、
268 より高い優先度のプロセス全てが停止 (block) した場合に実行を再開する。
270 .\"O When a \fBSCHED_FIFO\fP process becomes runnable, it
271 .\"O will be inserted at the end of the list for its priority.
272 \fBSCHED_FIFO\fP プロセスが実行可能になった時、その優先度のリストの最後
276 .\"O .BR sched_setscheduler ()
278 .\"O .BR sched_setparam (2)
280 .\"O \fBSCHED_FIFO\fP (or \fBSCHED_RR\fP) process identified by
281 .\"O \fIpid\fP at the start of the list if it was runnable.
282 .BR sched_setscheduler ()
284 .BR sched_setparam (2)
286 \fIpid\fP で指定された \fBSCHED_FIFO\fP (または \fBSCHED_RR\fP) プロセスが
288 .\"O As a consequence, it may preempt the currently running process if
289 .\"O it has the same priority.
290 .\"O (POSIX.1-2001 specifies that the process should go to the end
293 現在実行中のプロセスに先んじるかもしれない。
294 (POSIX.1-2001 ではプロセスはリストの最後に行くべきと規定されている。)
295 .\" In 2.2.x and 2.4.x, the process is placed at the front of the queue
296 .\" In 2.0.x, the Right Thing happened: the process went to the back -- MTK
298 .\"O A process calling
299 .\"O .BR sched_yield (2)
300 .\"O will be put at the end of the list.
302 を呼び出したプロセスはリストの最後に置かれる。
304 .\"O No other events will move a process
305 .\"O scheduled under the \fBSCHED_FIFO\fP policy in the wait list of
306 .\"O runnable processes with equal static priority.
307 その他のイベントによって \fBSCHED_FIFO\fP ポリシーで
308 スケジューリングされるプロセスが同じ優先度の実行可能な
309 プロセスの待ちリストの中を移動することはない。
311 .\"O A \fBSCHED_FIFO\fP
312 .\"O process runs until either it is blocked by an I/O request, it is
313 .\"O preempted by a higher priority process, or it calls
314 .\"O .BR sched_yield (2).
315 \fBSCHED_FIFO\fP プロセスは I/O 要求によって停止するか、
316 より高い優先度のプロセスによって置きかえられるか、
319 .\"O .SS SCHED_RR: Round Robin scheduling
320 .SS SCHED_RR: ラウンド・ロビン (round robin) ・スケジューリング
321 .\"O \fBSCHED_RR\fP is a simple enhancement of \fBSCHED_FIFO\fP.
323 .\"O described above for \fBSCHED_FIFO\fP also applies to \fBSCHED_RR\fP,
324 .\"O except that each process is only allowed to run for a maximum time
326 .\"O If a \fBSCHED_RR\fP process has been running for a time
327 .\"O period equal to or longer than the time quantum, it will be put at the
328 .\"O end of the list for its priority.
329 .\"O A \fBSCHED_RR\fP process that has
330 .\"O been preempted by a higher priority process and subsequently resumes
331 .\"O execution as a running process will complete the unexpired portion of
332 .\"O its round robin time quantum.
333 .\"O The length of the time quantum can be
335 .\"O .BR sched_rr_get_interval (2).
336 \fBSCHED_RR\fP は \fBSCHED_FIFO\fP の単純な拡張である。
337 上述された \fBSCHED_FIFO\fP に関する記述は全て \fBSCHED_RR\fP に
338 適用できる。異なるのはそれぞれのプロセスは最大時間単位までしか実行できない
339 ということである。\fBSCHED_RR\fP プロセスが時間単位と同じかそれより
340 長い時間実行されると、その優先度のリストの最後に置かれる。
341 より高い優先度のプロセスによって置きかえられ、その後実行を再開した
342 \fBSCHED_RR\fP プロセスは、そのラウンド・ロビン時間単位を完全に使い切る
344 .BR sched_rr_get_interval (2)
346 .\" On Linux 2.4, the length of the RR interval is influenced
347 .\" by the process nice value -- MTK
349 .\"O .SS SCHED_OTHER: Default Linux time-sharing scheduling
350 .SS SCHED_OTHER: Linux のデフォルトの時分割スケジューリング
351 .\"O \fBSCHED_OTHER\fP can only be used at static priority 0.
352 .\"O \fBSCHED_OTHER\fP is the standard Linux time-sharing scheduler that is
353 .\"O intended for all processes that do not require the special
354 .\"O real-time mechanisms.
355 .\"O The process to run is chosen from the static
356 .\"O priority 0 list based on a \fIdynamic\fP priority that is determined only
357 .\"O inside this list.
358 .\"O The dynamic priority is based on the nice value (set by
361 .\"O .BR setpriority (2))
362 .\"O and increased for each time quantum the process is ready to run,
363 .\"O but denied to run by the scheduler.
364 .\"O This ensures fair progress among all \fBSCHED_OTHER\fP processes.
365 \fBSCHED_OTHER\fP は静的優先度 0 でのみ使用できる。
366 \fBSCHED_OTHER\fP は Linux 標準の時分割スケジューラで、
367 特別なリアルタイム機構を必要としていない全てのプロセスで使用される。
368 実行するプロセスは、静的優先度 0 のリストから、このリストの中だけで
369 決定される「動的な」優先度 (dynamic priority) に基いて決定される。
374 により設定される) nice 値に基づいて決定されるもので、
375 単位時間毎に、プロセスが実行可能だが、スケジューラにより実行が拒否された
377 これにより、全ての \fBSCHED_OTHER\fP プロセスでの公平性が保証される。
379 .\"O .SS SCHED_BATCH: Scheduling batch processes
380 .SS SCHED_BATCH: バッチプロセスのスケジューリング
381 .\"O (Since Linux 2.6.16.)
383 .\"O \fBSCHED_BATCH\fP can only be used at static priority 0.
384 .\"O This policy is similar to \fBSCHED_OTHER\fP in that it schedules
385 .\"O the process according to its dynamic priority
386 .\"O (based on the nice value).
387 .\"O The difference is that this policy
388 .\"O will cause the scheduler to always assume
389 .\"O that the process is CPU-intensive.
390 .\"O Consequently, the scheduler will apply a small scheduling
391 .\"O penalty with respect to wakeup behaviour,
392 .\"O so that this process is mildly disfavored in scheduling decisions.
393 \fBSCHED_BATCH\fP は静的優先度 0 でのみ使用できる。
394 このポリシーは (nice 値に基づく) 動的な優先度にしたがってプロセスの
395 スケジューリングが行われるという点で、\fBSCHED_OTHER\fP に似ている。
396 異なるのは、このポリシーでは、プロセスが常に CPU に負荷のかかる (CPU-intensive)
397 処理を行うと、スケジューラが仮定する点である。
398 スケジューラはプロセスを呼び起こす毎にそのプロセスにスケジューリング上の
399 ペナルティを少し課し、その結果、このプロセスはスケジューリングの決定で
402 .\" The following paragraph is drawn largely from the text that
403 .\" accompanied Ingo Molnar's patch for the implementation of
405 .\"O This policy is useful for workloads that are noninteractive,
406 .\"O but do not want to lower their nice value,
407 .\"O and for workloads that want a deterministic scheduling policy without
408 .\"O interactivity causing extra preemptions (between the workload's tasks).
409 このポリシーは、非対話的な処理だがその nice 値を下げたくない処理や、
410 (処理のタスク間で) 余計なタスクの置き換えの原因とある対話的な処理なしで
411 確定的な (deterministic) スケジューリング・ポリシーを適用したい処理に
414 .\"O .SS SCHED_IDLE: Scheduling very low priority jobs
415 .SS SCHED_IDLE: 非常に優先度の低いジョブのスケジューリング
416 .\"O (Since Linux 2.6.23.)
418 .\"O \fBSCHED_IDLE\fP can only be used at static priority 0;
419 .\"O the process nice value has no influence for this policy.
420 \fBSCHED_IDLE\fP は静的優先度 0 でのみ使用できる。
421 このポリシーではプロセスの nice 値はスケジューリングに影響を与えない。
423 .\"O This policy is intended for running jobs at extremely low
424 .\"O priority (lower even than a +19 nice value with the
429 非常に低い優先度でのジョブの実行を目的としたものである
434 での nice 値 +19 よりさらに低い優先度である)。
436 .\"O .SS Privileges and resource limits
438 .\"O In Linux kernels before 2.6.12, only privileged
439 .\"O .RB ( CAP_SYS_NICE )
440 .\"O processes can set a nonzero static priority (i.e., set a real-time
441 .\"O scheduling policy).
442 .\"O The only change that an unprivileged process can make is to set the
444 .\"O policy, and this can only be done if the effective user ID of the caller of
445 .\"O .BR sched_setscheduler ()
446 .\"O matches the real or effective user ID of the target process
447 .\"O (i.e., the process specified by
449 .\"O whose policy is being changed.
450 2.6.12 より前のバージョンの Linux カーネルでは、
453 ケーパビリティを持つプロセス) だけが 0 以外の静的優先度を設定する
454 (すなわち、リアルタイム・スケジューリング・ポリシーを設定する) ことができる。
457 ポリシーを設定することだけであり、さらにこの変更を行えるのは
458 .BR sched_setscheduler ()
459 の呼び出し元の実効ユーザ ID がポリシーの変更対象プロセス
461 で指定されたプロセス) の実ユーザ ID か実効ユーザ ID と
464 .\"O Since Linux 2.6.12, the
465 .\"O .B RLIMIT_RTPRIO
466 .\"O resource limit defines a ceiling on an unprivileged process's
467 .\"O static priority for the
472 Linux 2.6.12 以降では、リソース制限
479 の場合の、非特権プロセスの静的優先度の上限を定めている。
480 .\"O The rules for changing scheduling policy and priority are as follows:
481 スケジューリング・ポリシーと優先度を変更する際のルールは以下の通りである。
483 .\"O If an unprivileged process has a nonzero
484 .\"O .B RLIMIT_RTPRIO
485 .\"O soft limit, then it can change its scheduling policy and priority,
486 .\"O subject to the restriction that the priority cannot be set to a
487 .\"O value higher than the maximum of its current priority and its
488 .\"O .B RLIMIT_RTPRIO
493 非特権プロセスはそのプロセスのスケジューリング・ポリシーと優先度を
494 変更できるが、優先度を現在の自身の優先度と
496 ソフト・リミットの大きい方よりも高い値に設定できないという制限が課される。
499 .\"O .B RLIMIT_RTPRIO
500 .\"O soft limit is 0, then the only permitted changes are to lower the priority,
501 .\"O or to switch to a non-real-time policy.
503 ソフト・リミットが 0 の場合、優先度を下げるか、
504 リアルタイムでないポリシーへ切り替えるかの変更だけが許可される。
506 .\"O Subject to the same rules,
507 .\"O another unprivileged process can also make these changes,
508 .\"O as long as the effective user ID of the process making the change
509 .\"O matches the real or effective user ID of the target process.
510 ある非特権プロセスが別のプロセスに対してこれらの変更を行う際にも、
511 同じルールが適用される。変更を行えるのは、変更を行おうとするプロセス
512 の実効ユーザ ID が変更対象のプロセスの実ユーザ ID か実効ユーザ ID と
515 .\"O Special rules apply for the
516 .\"O .BR SCHED_IDLE :
517 .\"O an unprivileged process operating under this policy cannot
518 .\"O change its policy, regardless of the value of its
519 .\"O .BR RLIMIT_RTPRIO
523 このポリシーの下で動作する非特権プロセスは、リソース制限
525 の値にかかわらず自身のポリシーを変更することができない。
528 .\"O .RB ( CAP_SYS_NICE )
529 .\"O processes ignore the
530 .\"O .B RLIMIT_RTPRIO
531 .\"O limit; as with older kernels,
532 .\"O they can make arbitrary changes to scheduling policy and priority.
538 古いカーネルと同じように、スケジューリング・ポリシーと優先度に対し
541 .\"O .BR getrlimit (2)
542 .\"O for further information on
543 .\"O .BR RLIMIT_RTPRIO .
548 .\"O .SS Response time
549 .SS 応答時間 (response time)
550 .\"O A blocked high priority process waiting for the I/O has a certain
551 .\"O response time before it is scheduled again.
552 .\"O The device driver writer
553 .\"O can greatly reduce this response time by using a "slow interrupt"
554 .\"O interrupt handler.
555 .\"O .\" as described in
556 .\"O .\" .BR request_irq (9).
557 I/O 待ちで停止したより高い優先度のプロセスは再びスケジューリングされる
558 前にいくらかの応答時間がかかる。デバイス・ドライバーを書く場合には
559 .\" .BR request_irq (9)
561 "slow interrupt" 割り込みハンドラーを使用することで
562 この応答時間を劇的に減少させることができる。
563 .\"O .SS Miscellaneous
565 .\"O Child processes inherit the scheduling policy and parameters across a
567 .\"O The scheduling policy and parameters are preserved across
571 の際に親プロセスのスケジューリング・ポリシーとパラメータを継承する。
573 の前後で、スケジューリング・ポリシーとパラメータは保持される。
575 .\"O Memory locking is usually needed for real-time processes to avoid
576 .\"O paging delays; this can be done with
579 .\"O .BR mlockall (2).
580 リアルタイム・プロセスは大抵、ページングの待ち時間を避けるために
584 を使ってメモリ・ロックをしなければならない。
586 .\"O Since a nonblocking infinite loop in a process scheduled under
587 .\"O \fBSCHED_FIFO\fP or \fBSCHED_RR\fP will block all processes with lower
588 .\"O priority forever, a software developer should always keep available on
589 .\"O the console a shell scheduled under a higher static priority than the
590 .\"O tested application.
591 .\"O This will allow an emergency kill of tested
592 .\"O real-time applications that do not block or terminate as expected.
593 \fBSCHED_FIFO\fP や \fBSCHED_RR\fP でスケジューリングされる
595 他の全てのより低い優先度のプロセスを永久に停止 (block) させてしまうので、
596 ソフトウェア開発者はコンソールのシェルの静的優先度をテストする
597 アプリケーションよりも常に高く保つべきである。
598 これによって期待通りに停止したり終了したりしないリアルタイム・
599 アプリケーションを緊急終了させることが可能になる。
600 .\"O See also the description of the
601 .\"O .BR RLIMIT_RTTIME
602 .\"O resource limit in
603 .\"O .BR getrlimit (2).
609 .\"O POSIX systems on which
610 .\"O .BR sched_setscheduler ()
612 .\"O .BR sched_getscheduler ()
613 .\"O are available define
614 .\"O .B _POSIX_PRIORITY_SCHEDULING
615 .\"O in \fI<unistd.h>\fP.
616 POSIX システムでは \fI<unistd.h>\fP に
617 .B _POSIX_PRIORITY_SCHEDULING
619 .BR sched_setscheduler ()
621 .BR sched_getscheduler ()
623 .\"O .SH "RETURN VALUE"
626 .\"O .BR sched_setscheduler ()
629 .\"O .BR sched_getscheduler ()
630 .\"O returns the policy for the process (a nonnegative integer).
631 .\"O On error, \-1 is returned, and
633 .\"O is set appropriately.
635 .BR sched_setscheduler ()
638 .BR sched_getscheduler ()
639 は現在のそのプロセスのポリシー (非負の整数) を返す。
647 .\"O The scheduling \fIpolicy\fP is not one of the recognized policies,
648 .\"O or \fIparam\fP does not make sense for the \fIpolicy\fP.
649 スケジューリング・ポリシー \fIpolicy\fP が間違っているか、
650 \fIparam\fP がそのポリシーでは意味をなさない。
653 .\"O The calling process does not have appropriate privileges.
654 呼び出したプロセスが適切な特権を持っていない。
657 .\"O The process whose ID is \fIpid\fP could not be found.
658 IDが \fIpid\fP のプロセスが見つからない。
659 .\"O .SH "CONFORMING TO"
661 .\"O POSIX.1-2001 (but see BUGS below).
662 .\"O The \fBSCHED_BATCH\fP and \fBSCHED_IDLE\fP policies are Linux-specific.
663 POSIX.1-2001 (但し、下記のバグの節も参照)。
664 \fBSCHED_BATCH\fP と \fBSCHED_IDLE\fP ポリシーは Linux 固有である。
667 .\"O POSIX.1 does not detail the permissions that an unprivileged
668 .\"O process requires in order to call
669 .\"O .BR sched_setscheduler (),
670 .\"O and details vary across systems.
671 .\"O For example, the Solaris 7 manual page says that
672 .\"O the real or effective user ID of the calling process must
673 .\"O match the real user ID or the save set-user-ID of the target process.
675 .BR sched_setscheduler ()
676 を呼び出すために必要な権限の詳細を規定しておらず、
678 例えば、Solaris 7 のマニュアルページでは、
679 呼び出し元プロセスの実ユーザ ID または実効ユーザ ID が
680 設定対象のプロセスの実ユーザ ID か保存 (save) set-user-ID と
681 一致していなければならない、となっている。
683 .\"O Originally, Standard Linux was intended as a general-purpose operating
684 .\"O system being able to handle background processes, interactive
685 .\"O applications, and less demanding real-time applications (applications that
686 .\"O need to usually meet timing deadlines).
687 もともとは、標準の Linux は一般目的のオペレーティングシステムとして
688 設計されており、バックグラウンド・プロセスや対話的アプリケーション、
689 リアルタイム性の要求が厳しくないリアルタイム・アプリケーション
690 (普通はタイミングの応答期限 (deadline) を満たす必要があるアプリケーション)
692 .\"O Although the Linux kernel 2.6
693 .\"O allowed for kernel preemption and the newly introduced O(1) scheduler
694 .\"O ensures that the time needed to schedule is fixed and deterministic
695 .\"O irrespective of the number of active tasks, true real-time computing
696 .\"O was not possible up to kernel version 2.6.17.
698 カーネルのプリエンプション (タスクの置き換え) が可能であり、
699 新たに導入された O(1) スケジューラにより、
700 アクティブなタスクの数に関わらずスケジューリングに必要な時間は
701 固定で確定的 (deterministic) であることが保証されている。
702 それにも関わらず、カーネル 2.6.17 までは
703 真のリアルタイム・コンピューティングは実現できなかった。
704 .\"O .SS Real-time features in the mainline Linux kernel
705 .SS 本流の Linux カーネルでのリアルタイム機能
706 .\" FIXME . Probably this text will need some minor tweaking
707 .\" by about the time of 2.6.30; ask Carsten Emde about this then.
708 .\"O From kernel version 2.6.18 onwards, however, Linux is gradually
709 .\"O becoming equipped with real-time capabilities,
710 .\"O most of which are derived from the former
711 .\"O .I realtime-preempt
712 .\"O patches developed by Ingo Molnar, Thomas Gleixner,
713 .\"O Steven Rostedt, and others.
714 .\"O Until the patches have been completely merged into the
716 .\"O (this is expected to be around kernel version 2.6.30),
717 .\"O they must be installed to achieve the best real-time performance.
719 Linux は徐々にリアルタイム機能を備えつつあるが、
721 Ingo Molnar, Thomas Gleixner, Steven Rostedt らによって開発された、
725 これらのパッチが本流のカーネルに完全にマージされるまでは
726 (マージの完了はカーネル 2.6.30 あたりの予定)、
727 最高のリアルタイム性能を達成するには realtime-preempt パッチを
729 .\"O These patches are named:
734 patch-\fIkernelversion\fP-rt\fIpatchversion\fP
738 .\"O and can be downloaded from
739 .\"O .IR http://www.kernel.org/pub/linux/kernel/projects/rt/ .
741 .I http://www.kernel.org/pub/linux/kernel/projects/rt/
744 .\"O Without the patches and prior to their full inclusion into the mainline
745 .\"O kernel, the kernel configuration offers only the three preemption classes
746 .\"O .BR CONFIG_PREEMPT_NONE ,
747 .\"O .BR CONFIG_PREEMPT_VOLUNTARY ,
749 .\"O .B CONFIG_PREEMPT_DESKTOP
750 .\"O which respectively provide no, some, and considerable
751 .\"O reduction of the worst-case scheduling latency.
752 このパッチが適用されず、かつパッチの内容の本流のカーネルへのマージが
754 .BR CONFIG_PREEMPT_NONE ,
755 .BR CONFIG_PREEMPT_VOLUNTARY ,
756 .B CONFIG_PREEMPT_DESKTOP
757 の 3つのプリエンプション・クラス (preemption class) だけが提供される。
758 これらのクラスでは、最悪の場合のスケジューリング遅延がそれぞれ
761 .\"O With the patches applied or after their full inclusion into the mainline
762 .\"O kernel, the additional configuration item
763 .\"O .B CONFIG_PREEMPT_RT
764 .\"O becomes available.
765 .\"O If this is selected, Linux is transformed into a regular
766 .\"O real-time operating system.
767 パッチが適用された場合、またはパッチの内容の本流のカーネルへのマージが
768 完了した後では、上記に加えて設定項目として
771 Linux は通常のリアルタイム・オペレーティングシステムに変身する。
772 .\"O The FIFO and RR scheduling policies that can be selected using
773 .\"O .BR sched_setscheduler ()
774 .\"O are then used to run a process
775 .\"O with true real-time priority and a minimum worst-case scheduling latency.
777 .BR sched_setscheduler ()
778 で選択できる FIFO と RR のスケジューリング・ポリシーは、
779 真のリアルタイム優先度を持つプロセスを最悪の場合のスケジューリング遅延が
780 最小となる環境で動作させるために使われることになる。
783 .\"O POSIX says that on success,
784 .\"O .BR sched_setscheduler ()
785 .\"O should return the previous scheduling policy.
787 .\"O .BR sched_setscheduler ()
788 .\"O does not conform to this requirement,
789 .\"O since it always returns 0 on success.
791 .BR sched_setscheduler ()
792 は直前のスケジューリング・ポリシーを返すべきとされている。
794 .BR sched_setscheduler ()
805 .BR sched_get_priority_max (2),
806 .BR sched_get_priority_min (2),
807 .BR sched_getaffinity (2),
808 .BR sched_getparam (2),
809 .BR sched_rr_get_interval (2),
810 .BR sched_setaffinity (2),
811 .BR sched_setparam (2),
814 .BR capabilities (7),
817 .I Programming for the real world \- POSIX.4
818 by Bill O. Gallmeister, O'Reilly & Associates, Inc., ISBN 1-56592-074-0
820 .\"O The kernel source file
821 .\"O .I Documentation/scheduler/sched-rt-group.txt
822 .\"O (since kernel 2.6.25).
824 .I Documentation/scheduler/sched-rt-group.txt