chrt命令
用户使用chrt命令可以很简单地更改调度策略。RHEL5版本的chrt命令中不存在指定SCHED_IDLE的-i选项。
在CentOS5(RHEL5)中chrt的使用方法如下所示。
$chrt—help
chrt(util-linux 2.13-pre7)
usage:chrt[options][prio][pid|cmd[args……]]
manipulate real-time attributes of a process
-b,—batch set policy to SCHED_BATCH
-f,—fifo set policy to SCHED_FF
-p,—pid operate on existing given pid
-m,—max show min and max valid priorities
-o,—other set policy to SCHED_OTHER
-r,—rr set policy to SCHED_RR(default)
-h,—help display this help
-v,—verbose display status information
-V,—version output version information
下面是Fedora 12(RHEL6)中chrt的使用方法。
$chrt—help
chrt-manipulate real-time attributes of a process.
Set policy:
chrt[options]<policy><priority>{<pid>|<command>[<arg>……]}
Get policy:
chrt[options]{<pid>|<command>[<arg>……]}
Scheduling policies:
-b|—batch set policy to SCHED_BATCH
-f|—fifo set policy to SCHED_FIFO
-i|—idle set policy to SCHED_IDLE
-o|—other set policy to SCHED_OTHER
-r|—rr set policy to SCHED_RR(default)
Options:
-h|—help display this help
-p|—pid operate on existing given pid
-m|—max show min and max valid priorities
-v|—verbose display status information
-V|—version output version information
使用chrt命令,可以更改进程的调度策略和优先级。例如,使用SCHED_IDLE解压缩内核源代码存档时的命令行如下所示。
$chrt-i o tar jxf linux-2.6.33.tar.bz2
正在运行的进程的调度策略也可以通过指定目的进程的PID来更改。
chrt-p-r 99<pid>
另外,使用实时调度策略,必须具有root权限。