Why we define Scheduler timeslice in CFS also?
To be specific, I am talking about Linux kernel Scheduling system after CFS patch merged.
Everywhere it is mentioned that in the CFS (completely fair scheduler) there is no fixed timeslice for the process and timeslice is calculated based on the equal division of the number of processes running in the system as they were executing in parallel in hardware. Figure explains it more ..
Still why we define the scheduler timeslice in the kernel? http://lxr.free-electrons.com/source/include/linux/sched/rt.h#L62
Like the comment in the link says, that is the default time slice. For each scheduler implemented, the value of the time slices may change, if it makes sense.
For example, in the real time scheduler with the SCHED_RR
policy, you can see a default time slice is used, whereas for the SCHED_FIFO
policy the time slice is 0 because tasks with the SCHED_FIFO
policy must preempt every other task.
In the case of Completely Fair Scheduling, the time slice is computed in get_rr_interval_fair
by calling sched_slice
. It computes the slice based on the number of running tasks and its weight (which in turn is determined by the process' nice level).
上一篇: 多级反馈队列调度