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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) Tom Bjorkholm, Markus Kuhn & David A. Wheeler 1996-1999
.\"
.\" 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.
.\"
.\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
.\" First version written
.\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
.\" revision
.\" 1999-08-18 David A. Wheeler <dwheeler@ida.org> added Note.
.\" Modified, 25 Jun 2002, Michael Kerrisk <mtk-manpages@gmx.net>
.\" Corrected description of queue placement by sched_setparam() and
.\" sched_setscheduler()
.\" A couple of grammar clean-ups
.\" Modified 2004-05-27 by Michael Kerrisk <mtk-manpages@gmx.net>
.\"
.\" Japanese Version Copyright (c) 1996 Akira Yoshiyama
.\" all rights reserved.
.\" Translated Thu Jul 11 01:42:52 JST 1996
.\" by Akira Yoshiyama <yosshy@jedi.seg.kobe-u.ac.jp>
.\" Modified Sun Nov 21 19:36:18 JST 1999
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated Wed Jan 1 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.TH SETSCHEDULER 2 2004-05-27 "Linux 2.6.6" "Linux Programmer's Manual"
.SH ̾
sched_setscheduler, sched_getscheduler \-
塼르ꥺȥѥ/
.SH
.B #include <sched.h>
.sp
.BI "int sched_setscheduler(pid_t " pid ", int " policy ,
.BI "const struct sched_param *" p );
.sp
.BI "int sched_getscheduler(pid_t " pid );
.sp
.nf
.ta 4n
\fBstruct sched_param {
...
int \fIsched_priority\fB;
...
};
.ta
.fi
.SH
.B sched_setscheduler
\fIpid\fP ˤäƼ̤ץΥ塼ˤ
˴Ϣѥꤹ롣\fIpid\fP ξ
ƤӽФץΥ塼ꤵ롣
ѥ \fIp\fP β줿ˤˤ롣ߡLinux Ǥ
ʲ3ĤΥ塼ˤݡȤƤ:
.IR SCHED_FIFO ,
.IR SCHED_RR ,
.IR SCHED_OTHER
줾ˤĤƤϰʲǽҤ٤롣
.B sched_getscheduler
\fIpid\fP Ǽ̤ץ˸ŬѤƤ
塼ˤҤͤ롣\fIpid\fP ʤСƤӽФ
ץȤΥ塼ˤ֤롣
.SS 塼(scheduling policy)
塼顼(scheduler)Ȥϥͥΰǡ CPU Ǽ¹Ԥ
¹Բǽʥץꤹ롣Linux Υ塼顼ϻĤΰۤä
塼ˤƤꡢĤ̾ΥץΤ
Ĥϥꥢ륿(real-time)ץꥱΤ˻Ȥ롣
Ūͥ(static priority) \fIsched_priority\fP
ƤΥץ˻ꤵ졢ͤϥƥࡦ̤ƤΤѹǤ롣
\fIsched_priority\fP 0 99 ϰϤͤ뤳ȤǤ
塼顼Ϥ \fIsched_priority\fP ͤ줾Ф
¹ԲǽʥץΥꥹȤƤ롣˼¹Ԥץ
ꤹ뤿ˡLinux Υ塼顼Ūͥ٤κǤ⤤
ǤʤꥹȤõơΥꥹȤƬΥץФ
塼ˤϤ줾ΥץƱŪͥ٤
ץΥꥹȤΤɤ졢ΥꥹȤɤΤ褦
ư뤫ꤹ롣
\fISCHED_OTHER\fP ϥǥեȤΰŪʻʬ䷿塼ˤǡ
¿ΥץˤäƻѤ롣\fISCHED_FIFO\fP \fISCHED_RR\fP
Ϥɤμ¹Բǽץ뤫ˤĤơΤɬפȤ
֤üʥץꥱΤΤΤǤ롣
\fISCHED_OTHER\fP ǥ塼ƤץŪͥ
Ȥ 0 ꤵʤФʤ餺\fISCHED_FIFO\fP \fISCHED_RR\fP
ǥ塼Ƥץ 1 99 ϰϤ
Ūͥ٤뤳ȤǤ롣
ѡ桼øĥץΤߤ 0 礭Ūͥ٤
뤳ȤǤ\fISCHED_FIFO\fP \fISCHED_RR\fP ǥ塼
Ǥ롣\fBsched_get_priority_min\fP \fBsched_get_priority_max\fP
ƥࡦѤ뤳ȤƤ POSIX.1b ߴƥ
ܿǽˡͭͥ٤ϰϤ뤳ȤǤ롣
ƤΥ塼ϥץꥨץƥ(preemptive)Ǥ:
⤤ͥ٤Υץμ¹ԤνǤȡߤΥץ
ͥŪʤΤ֤(preempt)ԤꥹȤᤵ롣
塼ˤƱŪͥ٤ļ¹Բǽʥץ
ꥹȤǽ֤Τߤꤹ롣
.SS SCHED_FIFO: եȥեȥȡ塼
\fISCHED_FIFO\fP 0 礭Ūͥ٤ǤΤѤǤ
\fISCHED_FIFO\fP ץ¹Բǽˤʤä硢ˡ
¹ԤƤ̤ \fISCHED_OTHER\fP ץ֤롣
\fISCHED_FIFO\fP ϻʬΤʤñʥ塼르ꥺǤ롣
\fISCHED_FIFO\fP ˤǥ塼Ƥץˤϰʲ
§ŬѤ: ⤤ͥ٤¾Υץˤä֤줿
\fISCHED_FIFO\fP ץϤͥ٤ΥꥹȤƬαޤ³
⤤ͥ٤ΥץƤ(block)ˤϺƤӼ¹Ԥ³롣
\fISCHED_FIFO\fP ץ¹Բǽˤʤäͥ٤ΥꥹȤκǸ
롣\fBsched_setscheduler\fP \fBsched_setparam\fP
\fIpid\fP ǻꤵ줿 \fISCHED_FIFO\fP (ޤ \fISCHED_RR\fP) ץ
¹Բǽʾ硢ꥹȤκǽ֤
̤Ȥơ⤷ץ饤ƥƱä硢
¹Υץ뤫⤷ʤ
(POSIX 1003.1 ǤϥץϥꥹȤκǸ˹Ԥ٤ȵꤵƤ롣)
\fBsched_yield\fP ƤӽФץϥꥹȤ
Ǹ֤롣¾Υ٥Ȥˤä \fISCHED_FIFO\fP ˤ
塼ץƱͥ٤μ¹Բǽʥץ
ԤꥹȤư뤳ȤϤʤ\fISCHED_FIFO\fP ץ
I/O ˤäߤ뤫⤤ͥ٤Υץˤä֤
뤫\fBsched_yield\fP ƤӽФޤǼ¹Ԥ³롣
.SS SCHED_RR: 饦ɡӥ(round robin)塼
\fISCHED_RR\fP \fISCHED_FIFO\fP ñʳĥǤ롣
Ҥ줿 \fISCHED_FIFO\fP ˴ؤ뵭Ҥ \fISCHED_RR\fP
ŬѤǤ롣ۤʤΤϤ줾ΥץϺñ̤ޤǤ¹ԤǤʤ
ȤȤǤ롣\fISCHED_RR\fP ץñ̤Ʊ
Ĺּ¹Ԥȡͥ٤ΥꥹȤκǸ֤롣
⤤ͥ٤Υץˤä֤졢θ¹ԤƳ
\fISCHED_RR\fP ץϡΥ饦ɡӥñ̤˻Ȥڤ
ޤǼ¹Ԥ롣λñ̤Ĺ \fBsched_rr_get_interval\fP
äƼǤ롣
.\" On Linux 2.4, the length of the RR interval is influenced
.\" by the process nice value -- MTK
.SS SCHED_OTHER: Linux ΥǥեȤλʬ䥹塼
\fISCHED_OTHER\fP Ūͥ 0 ǤΤѤǤ롣
\fISCHED_OTHER\fP Linux ɸλʬ䥹塼顼ǡ
üŪͥ٤ꥢ롦ൡɬפȤƤʤƤ
ץǻѤ롣¹ԤץŪͥ 0 ΥꥹȤ
Τߤ顢ưŪͥ(dynamic priority)˴𤤤Ʒꤵ롣
ưŪͥ٤(\fBnice\fP \fBsetpriority\fP ƥࡦ
äꤵ) nice ٥˴ŤƤ롣ͤϥץ
¹ԽǤƤꡢ塼顼ˤäƼ¹ԤݤƤ֡
ñ̤Ȥ˥Ȥ롣Ƥ \fISCHED_OTHER\fP
ץ˸ʿǤ뤳Ȥݾڤ롣
.SS (response time)
I/O Ԥߤ⤤ͥ٤ΥץϺƤӥ塼
ˤ餫α֤롣ǥХɥ饤Сˤ
.\" .BR request_irq (9)
.\" ˵ҤƤ
"slow interrupt" ߥϥɥ顼Ѥ뤳Ȥ
α֤Ū˸뤳ȤǤ롣
.SS ¾
ҥץ
.BR fork
κݤ˿ƥץΥ塼르ꥺѾ롣
ꥢ롦ࡦץڡԤ֤뤿
.B mlock
.BR mlockall
ȤäƥꡦåʤФʤʤ
\fISCHED_FIFO\fP \fISCHED_RR\fP ǥ塼
ץߤ̵¥롼פˤȡ
¾ƤΤ㤤ͥ٤Υץʵפ(block)ƤޤΤǡ
եȥȯԤϥΥŪͥ٤ƥȤ륢ץꥱ˹⤯ݤĤ٤Ǥ롣
ˤäƴ̤ߤ꽪λꤷʤꥢ롦ࡦ
ץꥱ۵λ뤳Ȥǽˤʤ롣
\fISCHED_FIFO\fP \fISCHED_RR\fP ץϡʵפ¾Υץ
ͥ褹뤳ȤǤ롢 Linux ǤϤˤϥ롼ȤΥץ
ΤߤͿ뤳ȤǤ롣
POSIX ƥǤ <unistd.h>
.I _POSIX_PRIORITY_SCHEDULING
ƤˤΤ
.B sched_setscheduler
.B sched_getscheduler
ѤǤ롣
.SH ֤
硢
.BR sched_setscheduler
ϥ֤
硢
.BR sched_getscheduler
ϸߤΤΥץ()֤
顼ξ硢\-1 ֤졢
.I errno
Ŭڤꤵ롣
.SH 顼
.TP
.B EINVAL
塼 \fIpolicy\fP ְäƤ뤫
ѥ \fIp\fP ˤǤϰ̣ʤʤ
.TP
.B EPERM
ƤӽФץŬڤʸ (Linux Ǥ
.B CAP_SYS_NICE
ѥӥƥ) äƤʤ
¤äץ
\fISCHED_FIFO\fP \fISCHED_RR\fP ˤͿ뤳ȤǤ롣
.BR sched_setscheduler
ƤӽФץϼ¸桼ID
.IR pid
ǻꤷץΥ桼ID ¸桼ID
¤äץǤʤФʤʤ
.TP
.B ESRCH
ID \fIpid\fP ΥץĤʤ
.SH
POSIX.1b ( POSIX.4)
.SH
ɸŪ Linux ϰŪΥڥ졼ƥƥʤΤǡ
Хå饦ɡץ䡢Ūץꥱ
եȡꥢ륿(soft real-time)ץꥱ
(̤Υߥα(deadline)ɬפʥץꥱ)롣
.PP
ɸŪ Linux (Ф 1ðʲ)¤ݾڤɬפäꡢ
ԤŪʻ֤ϡɡꥢ륿(hard real-time)
ץꥱݡȤ褦ˤ
.I ߷פƤʤ
¾ƤΰŪΥڥ졼ƥƥƱͤ Linux
ǰΥѥեޥǤϤʤ
ʿŪʥѥեޥ粽褦˥ǥƤ롣
Linux κǰξγ߽ʿŪʾ٤礭äƤ롣
(SMP ΤΥåΤ褦)ޤޤʥͥåĹĹԤ
ޤʿѻ֤餹˳ȯ줿¿Υѥեޥ
ɵѤˤäƺǰλ֤ä롣
¿ξǤϤ줬ʤ˾ư⤷
ϡɡꥢ륿ࡦץꥱȯƤˤ
RTLinux (http://www.rtlinux.org) RTAI (http://www.rtai.org)
Τ褦ʥꥢ륿ĥ줿
Linux 丷ꥢ롦ॢץꥱѤ߷פ줿
¾ OS λѤθ٤Ǥ롣
.SH Ϣ
.BR getpriority (2),
.BR mlock (2),
.BR mlockall (2),
.BR munlock (2),
.BR munlockall (2),
.BR nice (2),
.BR sched_get_priority_max (2),
.BR sched_get_priority_min (2),
.BR sched_getaffinity (2),
.BR sched_getparam (2),
.BR sched_rr_get_interval (2),
.BR sched_setaffinity (2),
.BR sched_setparam (2),
.BR sched_yield (2),
.BR setpriority (2),
.BR capabilities (7)
.PP
.I Programming for the real world \- POSIX.4
by Bill O. Gallmeister, O'Reilly & Associates, Inc., ISBN 1-56592-074-0
.br
.I IEEE Std 1003.1b-1993
(POSIX.1b )
.br
.I ISO/IEC 9945-1:1996
\- Ͽ POSIX.1 1996ǯǤǤꡢ
POSIX.1(1990), POSIX.1b(1993), POSIX.1c(1995), POSIX.1i(1995)
ƤεʤޤǤ롣
|