From owner-freebsd-stable Tue Oct 16 16:59:16 2001 Delivered-To: freebsd-stable@freebsd.org Received: from cx2037703-a.kenner1.la.home.com (cx2037703-a.kenner1.la.home.com [24.39.27.145]) by hub.freebsd.org (Postfix) with ESMTP id ED3FE37B40D; Tue, 16 Oct 2001 16:59:08 -0700 (PDT) Received: (from conrads@localhost) by cx2037703-a.kenner1.la.home.com (8.11.6/8.11.6) id f9GNx5V13343; Tue, 16 Oct 2001 18:59:05 -0500 (CDT) (envelope-from conrads) Message-ID: X-Mailer: XFMail 1.5.1 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200110161236.NAA17246@lion.mpc-data.co.uk> Date: Tue, 16 Oct 2001 18:59:05 -0500 (CDT) Organization: @Home Network From: Conrad Sabatier To: Mike Pumford Subject: Re: 0.00% CPU for all processes Cc: freebsd-stable@FreeBSD.ORG, freebsd-questions@FreeBSD.ORG Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 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