-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 22 Nov 2007, Kazim Zaidi wrote:
> On 22/11/2007, Raj Mathur <[EMAIL PROTECTED]> wrote:
> [snip]
>
> > So to sum up:
> >
> > Times when the CPU is executing user code is counted in %user.
> > Times when the CPU is executing a system call (or running any other
> > kernel code) is counted in %system.
> > Times when the CPU is waiting for some I/O to complete is counted
> > in %iowait.
>
> I'm not sure I understand this. When a process requests I/O, it is
> blocked (or removed from ready queue) and CPU moves on to execute
> next process in the ready-to-run-queue. When the I/O completes, an
> event wakes up the blocked process(es).
> A process may be waiting for its I/O while CPU executing some user
> code. Does this time counted in %user or %iowait?

When one process is waiting for I/O and another is running in (say) user 
state, the CPU is actually in user state.  That time will be accounted 
for in %user, not in %iowait.

> Times when the CPU is doing nothing is counted in %idle.
>
> > Since the CPU must be doing one of these things at any time, the
> > sum of these percentages will always be 100.
>
>  [snip]
>
> If %user and %iowait overlap, then why is the sum 100?
>
> Or, is %iowait the time when there are no processes in ready-queue
> because all of them are waiting for I/O? I think that is idle time
> and not iowait time.

Nope, that is %iowait time.  Idle is when no process is doing anything.

If you want to see this in action, do the following on a relatively 
unloaded system:

- - Open up one terminal and run: sar -u 1 10000
- - Open up another terminal and run: ls -lR / > /dev/null

Watch the %iowait times in the sar output go up as ls keeps waiting to 
read the disk.  Now start up some CPU-intensive process like glxgears 
(GNU Chess is even better) and watch the %iowait times go down.  This 
is because the time ls is spending waiting for I/O to complete is being 
soaked up by glxgears/gnuchess using up the CPU.

Regards,

- -- Raju
- -- 
Raj Mathur                [EMAIL PROTECTED]      http://kandalaya.org/
 Freedom in Technology & Software || February 2008 || http://freed.in/
       GPG: 78D4 FC67 367F 40E2 0DD5  0FEF C968 D0EF CC68 D17F
PsyTrance & Chill: http://schizoid.in/   ||   It is the mind that moves
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHRR4IyWjQ78xo0X8RAgiSAJ0T+DJdIV3jlUcFxgN0KI6idAsBEQCfbjdH
zPzt1qH4Dwtc7+cgWeNYiKw=
=zRlw
-----END PGP SIGNATURE-----

_______________________________________________
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/

Reply via email to