我正在寻找我的 Linux 内核的时间片(或量子)的值。
具体问题:
/proc
文件可以公开此类信息?最佳答案
为特定进程分配的量程may vary :
You can tune "slice" by adjusting sched_latency_ns and sched_min_granularity_ns, but note that "slice" is not a fixed quantum. Also note that CFS preemption decisions are based upon instantaneous state. A task may have received a full (variable) "slice" of CPU time, but preemption will be triggered only if a more deserving task is available, so a "slice" is not the "max uninterrupted CPU time" that you may expect it to be.. but it is somewhat similar.
这是因为 Completely Fair Scheduler ,默认的 Linux 调度程序,assigns a proportion of the processor到一个过程而不是一个固定的时间片。这意味着每个进程的时间片是 proportional to the current load and weighted by the process' priority value .
对于使用 SCHED_RR 的专用实时进程,默认时间片在 Linux 内核中定义为 include/linux/sched/rt.h 中的 RR_TIMESLICE
.
/*
* default timeslice is 100 msecs (used only for SCHED_RR tasks).
* Timeslices get refilled after they expire.
*/
#define RR_TIMESLICE (100 * HZ / 1000)
您可以使用 sched_rr_get_interval()
获取特定 SCHED_RR 进程的 SCHED_RR 间隔。
https://stackoverflow.com/questions/16401294/