How to know linux scheduler time slice?

backlash picture backlash · May 6, 2013 · Viewed 54.3k times · Source

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

Specific Questions:

  • Is there a /proc file which expose such an information ?
  • (Or) Is it well-defined in the Linux header of my distributions ?
  • (Or) Is there a C function of the Linux API (maybe sysinfo) that expose this value ?

Answer

Alexey Shmalko picture Alexey Shmalko · Jul 2, 2013

CFS (which is default scheduler for processes) has no fixed timeslice, it is calculated at runtime depending of targeted latency (sysctl_sched_latency) and number of running processes. Timeslice could never be less than minimum granularity (sysctl_sched_min_granularity).

Timeslice will be always between sysctl_sched_min_granularity and sysctl_sched_latency, which are defaults to 0.75 ms and 6 ms respectively and defined in kernel/sched/fair.c.

But actual timeslice isn't exported to user-space.