Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Oct 2001 18:59:05 -0500 (CDT)
From:      Conrad Sabatier <conrads@home.com>
To:        Mike Pumford <mpumford@mpc-data.co.uk>
Cc:        freebsd-stable@FreeBSD.ORG, freebsd-questions@FreeBSD.ORG
Subject:   Re: 0.00% CPU for all processes
Message-ID:  <XFMail.20011016185905.conrads@home.com>
In-Reply-To: <200110161236.NAA17246@lion.mpc-data.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

On 16-Oct-2001 Mike Pumford wrote:
> top on Linux is really slow compared to the BSD versions. It is slower
> to update and always consumes a significant chunk of CPU. BSD top seems
> much more efficient. Possibly down to the fact the BSD top gathers its 
> info with libkvm while linux top has to parse a load of files in /proc. I
> suspect there may be differences in the CPU usage calculation algorithm
> as well.

The calculation is different, yes.

A while back, I had written some code that enabled an application to
monitor its own CPU usage using kvm calls (in order to "trim back" certain
areas if the load went too high).  Interesting experiment, and it worked,
too, for the most part!

Some Linux-using friends asked if I could port the idea for them, so I
grabbed some Linux sources and looked at how top obtained its CPU
statistics and how it calculated the percentages.  I can't recall the exact
formula now, but it definitely differs.  The mechanism for obtaining the
info is also nowhere near as clean as it is in FreeBSD.

-- 
Conrad Sabatier <conrads@home.com>

Rules for Academic Deans:
        (1)  HIDE!!!!
        (2)  If they find you, LIE!!!!
                -- Father Damian C. Fandal


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20011016185905.conrads>