Why do processes with higher priority to be allocated more timeslice?
mulyadi.santosa at gmail.com
Mon Sep 26 03:51:16 EDT 2011
On Mon, Sep 26, 2011 at 09:16, Parmenides <mobile.parmenides at gmail.com> wrote:
> It seems that Linux's scheduler tends to allocate longer timeslice
> for processes with higher priority.
"tends".....yes, at least theoritically..... but not really in every
cases in reality....
>Actually, the CFS scheduler which
> is a new scheduler in Linux kernel also does the same thing. But, I
> think this way does not fit with scheduler's principle.
remember the keyword you ask? "fairness"? that is being fair to all
processes.... but since, there are always more processes than
processors, unfairness always happen.....
> The goal chased by a scheduler is low latency and high thoughput.
> Normally, a I/O-bound process has higher priority, while a CPU-bound
> process has lower priority.
you are referring above as dynamic priority, I believe. As for static
priority, quite likely, all I/O and CPU bound processes start at
static prio level 0
> So, a I/O-bound process (which has enough
> timeslice) can preempt a CPU-bound process easily.
yes, because I/O bound one sleep quite a long time and its dynamic
priority gets a bonus. But if it sleeps not quite long, the bonus
won't be too significant to "defeat" current running one, so it has to
wait longer to be run by processor.
>This way ensures
> lower latency. It is also necessary that CPU-bound processes are to be
> allocated longer timeslice to improve throughput owing to less process
> switch costs. That means lower priority processes (CPU-bound) should
> be allocated longer timeslice, whichs obviously conflicts with the
> actual practice taken by the Linux's scheduler. Any explanation?
What you refer initially is the time when time slice assignment is
strictly derived from the static/nice level. So e.g process with nice
level 0 has lesser time slice that nice level -5.
But as you can see, situation change dynamically during run time, thus
static prio must be taken into dynamic priority. And dynamic priority
itself, must take another factor for time slice calculation. Here,
sleep time comes into play.
Freelance Linux trainer and consultant
More information about the Kernelnewbies