如何知道Linux调度时间片? [英] How to know linux scheduler time slice?

查看:2826
本文介绍了如何知道Linux调度时间片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找我的Linux内核的时间片(或量子)的值。

I'm looking for the value of the time slice (or quantum) of my Linux kernel.

有没有这暴露出这样一个信息的/ proc 文件?

Is there a /proc file which expose such an information ?

(或者)是我的分布的Linux头它明确定义?

(Or) Is it well-defined in the Linux header of my distributions ?

(或)是否有Linux的API(也许SYSINFO),揭露出这个值的C函数?

(Or) Is there a C function of the Linux API (maybe sysinfo) that expose this value ?

先谢谢了。

推荐答案

默认的Linux时间片的实时进程是在Linux内核为 RR_TIMESLICE 中的在include / linux /排程/ rt.h

The default Linux timeslice for realtime processes is defined in the Linux kernel as RR_TIMESLICE in include/linux/sched/rt.h.

/*
 * default timeslice is 100 msecs (used only for SCHED_RR tasks).
 * Timeslices get refilled after they expire.
 */
#define RR_TIMESLICE            (100 * HZ / 1000)

需要注意的是分配给特定进程实际的量子可能会有所不同比这个值:

您可以调整切片,通过调整 sched_latency_ns
   sched_min_granularity_ns ,但请注意,切片是不是一个固定的
  量子。还注意到,CFS preemption决定是根据
  即时状态。任务可能已经收到一个完整的(变量)
  CPU时间的切片,但preemption将被触发仅当更
  值得的任务是可用的,所以一个切片是不是最大
  不间断的CPU时间,你可能会想到它是..但它是
  有些相似。

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.

不过,您可以使用 sched_rr_get_interval() 得到SCHED_RR间隔为给定的实时过程。

However, you can use sched_rr_get_interval() to get the SCHED_RR interval for a given realtime process.

这篇关于如何知道Linux调度时间片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆