如何检查除`ps`输出之外的进程调度策略

时间:2014-05-06 06:47:03

标签: linux shell busybox

我正在使用busybox版本的linux,并希望检查进程调度策略。 PS输出仅显示PID USER VSZ STAT COMMAND,与PS命令给出的任何选项无关。有没有其他方法可以检查进程调度策略?

提前致谢!!

2 个答案:

答案 0 :(得分:4)

您可以通过查看/proc/pocess_id/sched找到流程的日程安排信息。

例如:

awk '/policy/ {print $NF}' /proc/25/sched

会为您提供流程25的政策编号。

有关政策编号的详细信息,请查看man sched_setscheduler

Scheduling Policies:
    ...
   For  threads scheduled under one of the normal scheduling policies
   (SCHED_OTHER, SCHED_IDLE, SCHED_BATCH), sched_priority is not used
   in scheduling decisions (it must be specified as 0).

   Processes scheduled under one of the real-time policies
   (SCHED_FIFO, SCHED_RR) have a sched_priority value in the range 1
   (low)  to  99  (high).  (As the numbers imply, real-time threads
   always have higher priority than normal threads.)  Note well:
   POSIX.1-2001 requires an implementation to support only a minimum
   32 distinct priority levels for the real-time policies, and some
   systems supply  just  this  minimum.   Portable  programs should
   use sched_get_priority_min(2) and sched_get_priority_max(2) to
   find the range of priorities supported for a particular policy.

答案 1 :(得分:-1)

要知道内核配置了哪个IO调度程序,请输入:

cat /proc/config.gz |grep CONFIG_DEFAULT_IOSCHED