OSDN Git Service

Update drafts for LDP 3.67
[linuxjm/LDP_man-pages.git] / draft / man2 / sched_setscheduler.2
1 .\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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 .\" %%%LICENSE_END
24 .\"
25 .\"
26 .\"*******************************************************************
27 .\"
28 .\" This file was generated with po4a. Translate the source file.
29 .\"
30 .\"*******************************************************************
31 .\"
32 .\" Japanese Version Copyright (c) 1996 Akira Yoshiyama
33 .\"         all rights reserved.
34 .\" Translated Thu Jul 11 01:42:52 JST 1996
35 .\"         by Akira Yoshiyama <yosshy@jedi.seg.kobe-u.ac.jp>
36 .\" Modified Sun Nov 21 19:36:18 JST 1999
37 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
38 .\" Updated Wed Jan  1 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
39 .\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\" Updated & Modified 2005-10-10, Akihiro MOTOKI
41 .\" Updated 2006-04-16, Akihiro MOTOKI, Catch up to LDP v2.28
42 .\" Updated 2007-10-13, Akihiro MOTOKI, LDP v2.65
43 .\" Updated 2008-08-13, Akihiro MOTOKI, LDP v3.05
44 .\" Updated 2012-06-04, Akihiro MOTOKI <amotoki@gmail.com>
45 .\" Updated 2013-05-01, Akihiro MOTOKI <amotoki@gmail.com>
46 .\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
47 .\"
48 .TH SCHED_SETSCHEDULER 2 2014\-05\-21 Linux "Linux Programmer's Manual"
49 .SH 名前
50 sched_setscheduler, sched_getscheduler \- スケジューリングポリシーとパラメータを設定/取得する
51 .SH 書式
52 .nf
53 \fB#include <sched.h>\fP
54 .sp
55 \fBint sched_setscheduler(pid_t \fP\fIpid\fP\fB, int \fP\fIpolicy\fP\fB,\fP
56 .br
57 \fB                       const struct sched_param *\fP\fIparam\fP\fB);\fP
58 .sp
59 \fBint sched_getscheduler(pid_t \fP\fIpid\fP\fB);\fP
60 .sp
61 .fi
62 .SH 説明
63 \fBsched_setscheduler\fP() システムコールは、 \fIpid\fP で指定された ID
64 を持つスレッドのスケジューリングポリシーとスケジューリングパラメーターの両方を設定する。 \fIpid\fP が 0
65 の場合、呼び出したスレッド自身のスケジューリングポリシーとスケジューリングパラメーターが設定される。
66
67 The scheduling parameters are specified in the \fIparam\fP argument, which is a
68 pointer to a structure of the following form:
69
70 .nf
71 .in +4n
72 struct sched_param {
73     ...
74     int sched_priority;
75     ...
76 };
77 .in
78 .fi
79
80 In the current implementation, the structure contains only one field,
81 \fIsched_priority\fP.  The interpretation of \fIparam\fP depends on the selected
82 policy.
83
84 Currently, Linux supports the following "normal" (i.e., non\-real\-time)
85 scheduling policies as values that may be specified in \fIpolicy\fP:
86 .TP  14
87 \fBSCHED_OTHER\fP
88 .\" In the 2.6 kernel sources, SCHED_OTHER is actually called
89 .\" SCHED_NORMAL.
90 標準の、ラウンドロビンによる時分割型のスケジューリングポリシー。
91 .TP 
92 \fBSCHED_BATCH\fP
93 「バッチ」形式でのプロセスの実行用。
94 .TP 
95 \fBSCHED_IDLE\fP
96 「非常に」低い優先度で動作するバックグラウンドジョブ用。
97 .PP
98 For each of the above policies, \fIparam\->sched_priority\fP must be 0.
99
100 どの実行可能スレッドを選択するかについて、より正確な制御を必要とする 時間の制約が厳しい特別なアプリケーション用として、
101 いろいろな「リアルタイム」ポリシーもサポートされている。 プロセスがこれらのポリシーをいつ使用できるかを決めるルールについては、\fBsched\fP(7)
102 を参照。 \fIpolicy\fP には以下のリアルタイムポリシーを指定できる。
103 .TP  14
104 \fBSCHED_FIFO\fP
105 ファーストイン、ファーストアウト型のポリシー。
106 .TP 
107 \fBSCHED_RR\fP
108 ラウンドロビン型のポリシー。
109 .PP
110 For each of the above policies, \fIparam\->sched_priority\fP specifies a
111 scheduling priority for the thread.  This is a number in the range returned
112 by calling \fBsched_get_priority_min\fP(2)  and \fBsched_get_priority_min\fP(2)
113 with the specified \fIpolicy\fP.  On Linux, these system calls return,
114 respectively, 1 and 99.
115
116 Linux 2.6.32 以降では、 \fBsched_setscheduler\fP() を呼び出す際に \fIpolicy\fP に
117 \fBSCHED_RESET_ON_FORK\fP フラグを OR で指定できる。このフラグが指定されると、 \fBfork\fP(2)
118 で作成された子プロセスは特権が必要なスケジューリングポリシーを継承しない。 詳細は \fBsched\fP(7) を参照。
119
120 \fBsched_getscheduler\fP()  は \fIpid\fP で識別されるスレッドの現在のスケジューリングポリシーを返す。\fIpid\fP が 0
121 ならば、呼び出した スレッド自身のスケジューリングポリシーが返される。
122 .SH 返り値
123 成功した場合、 \fBsched_setscheduler\fP()  は 0 を返す。 成功した場合、 \fBsched_getscheduler\fP()
124 は現在のそのスレッドのポリシー (非負の整数) を返す。 エラーの場合、 どちらのコールも \-1 を返し、 \fIerrno\fP が適切に設定される。
125 .SH エラー
126 .TP 
127 \fBEINVAL\fP
128 無効な引き数: \fIpid\fP が負である、または \fIparam\fP が NULL である。
129 .TP 
130 \fBEINVAL\fP
131 (\fBsched_setscheduler\fP()) \fIpolicy\fP が認識できるポリシーではない。
132 .TP 
133 \fBEINVAL\fP
134 (\fBsched_setscheduler\fP()) 引き数 \fIparam\fP が指定された \fIpolicy\fP では意味を持たない。
135 .TP 
136 \fBEPERM\fP
137 呼び出したスレッドが適切な特権を持っていない。
138 .TP 
139 \fBESRCH\fP
140 ID が \fIpid\fP のスレッドが見つからなかった。
141 .SH 準拠
142 POSIX.1\-2001 (但し、下記のバグの節も参照)。 \fBSCHED_BATCH\fP と \fBSCHED_IDLE\fP ポリシーは Linux
143 固有である。
144 .SH 注意
145 Further details of the semantics of all of the above "normal" and
146 "real\-time" scheduling policies can be found in \fBsched\fP(7).
147
148 POSIX システムでは \fI<unistd.h>\fP に \fB_POSIX_PRIORITY_SCHEDULING\fP
149 が定義されている場合にのみ \fBsched_setscheduler\fP()  と \fBsched_getscheduler\fP()  が使用できる。
150
151 POSIX.1 は、非特権スレッドが \fBsched_setscheduler\fP()  を呼び出すために必要な権限の詳細を規定しておらず、
152 詳細はシステムにより異なる。 例えば、Solaris 7 のマニュアルページでは、 呼び出し元の実ユーザ ID または実効ユーザ ID が
153 設定対象の実ユーザ ID か保存 (save) set\-user\-ID と 一致していなければならない、となっている。
154 .PP
155 Linux では、 スケジューリングポリシーとスケジューリングパラメータは、 実際にはスレッド単位の属性である。 \fBgettid\fP(2)
156 の呼び出しの返り値をこのシステムコールの \fIpid\fP 引き数として渡すことができる。 \fIpid\fP に 0 を指定すると、
157 呼び出し元のスレッドの属性が設定される。 \fBgetpid\fP(2) コールからの返り値を \fIpid\fP に指定すると、
158 スレッドグループのメインスレッドの属性が設定される (POSIX スレッド API を使用している場合は、 \fBsched_*\fP(2)
159 システムコールの代わりに \fBpthread_setschedparam\fP(3), \fBpthread_getschedparam\fP(3), and
160 \fBpthread_setschedprio\fP(3) を使用すること)。
161 .SH バグ
162 POSIX では、成功時に \fBsched_setscheduler\fP()  は直前のスケジューリングポリシーを返すべきとされている。 Linux の
163 \fBsched_setscheduler\fP()  はこの要求仕様に準拠しておらず、 成功時には常に 0 を返す。
164 .SH 関連項目
165 .ad l
166 .nh
167 \fBnice\fP(2), \fBsched_get_priority_max\fP(2), \fBsched_get_priority_min\fP(2),
168 \fBsched_getaffinity\fP(2), \fBsched_getattr\fP(2), \fBsched_getparam\fP(2),
169 \fBsched_rr_get_interval\fP(2), \fBsched_setaffinity\fP(2), \fBsched_setattr\fP(2),
170 \fBsched_setparam\fP(2), \fBsched_yield\fP(2), \fBsetpriority\fP(2),
171 \fBcapabilities\fP(7), \fBcpuset\fP(7), \fBsched\fP(7)
172 .ad
173 .SH この文書について
174 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
175 である。プロジェクトの説明とバグ報告に関する情報は
176 http://www.kernel.org/doc/man\-pages/ に書かれている。