Other unices I've used (Digital UNIX for one) don't include sleeping
processes, so that the load average approximates the CPU usage when it's
less than 1. However, if sleeping processes are included, you can have a
high load average with the CPU being largely idle.
I'd be pleased to hear any thoughts on this.
Tim.
--
Tim Bell. | My parents keep asking me how school was. It's like saying,
bh...@cs.mu.oz.au | 'How was that drive-by shooting?' -- "My So-Called Life".
> I've been wondering why the load average calculation in linux includes
> processes which are sleeping (with sleep(1) or sleep(3)). Was this a
> particular design decision, or did it just end up like that?
It doesn't. I've just set off a number of sleeping processes with
sleep 1000 &
and loadaverage is, let me see, 0.02.
What the kernel *does* include is processes in non-interruptible sleep
state ('D' state in ps output, as opposed to 'S' state). These are
processes which are blocked in the middle of a synchronous kernel
operation, usually waiting for disk I/O to complete. So, processes
which are doing a lot of file I/O or which are swapping heavily will
count in the load average. This is usually better than ignoring such
processes --- if you have got a hundred processes swapping their
hearts out because of memory shortages, you really don't want to see a
load average of next to nothing just because the processes can't get
any work done!
(Those sleeping processes are still there. Load average now 0.01.)
Cheers,
Stephen.
It doesn't, IIRC.
--
James Youngman VG Gas Analysis Systems The trouble with the rat-race
Before sending advertising material, read is, even if you win, you're
http://www.law.cornell.edu/uscode/47/227.html still a rat.
>bh...@mundook.cs.mu.OZ.AU (Tim Bell) writes:
>> I've been wondering why the load average calculation in linux includes
>> processes which are sleeping (with sleep(1) or sleep(3)). Was this a
>> particular design decision, or did it just end up like that?
>It doesn't. I've just set off a number of sleeping processes with
> sleep 1000 &
>and loadaverage is, let me see, 0.02.
You're right. The program I was running wasn't doing what I thought it
was doing. I thought it was this:
while true; do
# do something
sleep 10
done
but it was this:
while true; do
# do something
done
Moral: always make sure you're debugging (or questioning!) the right thing.
Thanks to those who responded.
Tim.
--
Tim Bell .--_|\
bh...@cs.mu.oz.au / \
Department of Computer Science \_.--._/
University of Melbourne, Australia v