Re: Time slices on linux


Subject: Re: Time slices on linux
From: Christian Jaeger (christian.jaeger@sl.ethz.ch)
Date: Wed Sep 06 2000 - 03:55:13 MDT


At 3:53 Uhr +0200 6.9.2000, Justin Vallon wrote:
>It sounds like the kernel is doing exactly what you asked for. You
>have given the CPU-intensive perl-script a higher priority than MOL
>(also pretty CPU-intensitve if it is just spinning cycles).

Yes but I would expect to get the remaining cpu cycles more regularly.

>In reality, I believe it switches every 60th or 100th of a second.
>It may (probably) be deciding that your lower-priority process should
>not be getting any CPU time, because it has a lower-priority.

Yes, I'm supposing the same (linux setting up an interrupt timer to a
constant interval of i.e. 1/60 sec., and then deciding upon each switch
which process should be given the next time slice).

But even when running mol under the same priority (priority 0), it's quite
irregular, it apparently doesn't get cpu every 30th second constantly, but
only every 10th second or so. Maybe this is because mol doesn't require cpu
constantly and returning (going to sleep) before the end of a slice, and
thus in some way disturb the calculation of the scheduler (maybe the
scheduler decides "so mol has had a time slice (even if it didn't use the
whole of it), it will not get one again now even if it requires to be run
again now". Or perhaps there might even be some complicated feedback
effects?).

BTW the mouse pointer of Xwindows (under Xpmac) is far more regular under
the same conditions.

>
>The scheduler decides when to run a given process. You can try an
>experiment with two CPU-hog perl scripts, running at different nice
>levels. Check the ratio of CPU time between the two levels (ie: 10
>sec to 1 sec) to get an indication of how much weighting the
>scheduler gives to the two priority levels that you are using.

This is the result:
  PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
 1319 chris 20 0 1140 1140 920 R 0 66.3 0.8 1:02 perl
 1321 chris 15 10 1140 1140 920 R N 0 32.0 0.8 0:29 perl

So nice -10 (which is what I used for mol) means the process will be given
about half the weight by the scheduler.

I've read somewhere that there are kernel patches (from IBM? or another big
company) to enable linux to handle hundreds of processes/threads in running
state (current linux can't do that since it would have a big overhead, if I
remember correctly). Might be this would also help here. If I find time,
I'll try to find these patches (hoping they work on linuxppc...) and try
them out.

Hmm, I have another idea now:

Maybe MacOS under mol just has it's own artificial interrupt timer, set at
1/60 second or, for mouse pointer movement etc., dependant on cpu time and
not real time. Now if the perl process is running, mol doesn't get cpu in
time, or get only half the time slices it would get usually, so the
interrupt in mol is delayed, and so even if mol *gets* cpu every 30th
second, the timer hasn't reached zero and so the pointer is still not
updated.

OK, i'll stop now making weird assumptions

Christian.



This archive was generated by hypermail 2a24 : Wed Sep 06 2000 - 04:08:28 MDT