From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 3 00:57:41 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 91D7316A4CE for ; Wed, 3 Mar 2004 00:57:41 -0800 (PST) Received: from mail022.syd.optusnet.com.au (mail022.syd.optusnet.com.au [211.29.132.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9591443D1D for ; Wed, 3 Mar 2004 00:57:38 -0800 (PST) (envelope-from peterjeremy@optushome.com.au) Received: from server.vk2pj.dyndns.org (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) i238vTE31629; Wed, 3 Mar 2004 19:57:30 +1100 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1])i238vTi6017855; Wed, 3 Mar 2004 19:57:29 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.12.10/8.12.10/Submit) id i238vO0I017854; Wed, 3 Mar 2004 19:57:24 +1100 (EST) (envelope-from peter) Date: Wed, 3 Mar 2004 19:57:24 +1100 From: Peter Jeremy To: ticso@cicely.de Message-ID: <20040303085724.GA17162@server.vk2pj.dyndns.org> References: <20040303062730.GK44313@cicely12.cicely.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040303062730.GK44313@cicely12.cicely.de> User-Agent: Mutt/1.4.2.1i cc: freebsd-hackers@freebsd.org Subject: Re: how to get cpu states more than once a second? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2004 08:57:41 -0000 On Wed, Mar 03, 2004 at 07:27:31AM +0100, Bernd Walter wrote: >Currently I get the states via kern.cp_time, but this only allows >a granularity of a single second and I need something around 50-100ms. As far as I can tell - both by studying the source code and by running "sysctl -x kern.cp_time" in a loop - kern.cp_time increments continuously. statclock() increments the relevant element in the array by one at a rate of stathz (128Hz by default). Obviously, you need to smooth the result over a period substantially longer than 1/128 second to get a useful result (unless you want to pulse-width modulate your display) but 12.8Hz (stathz/10) would give you 10 samples which would be ideal for a 10-segment bargraph. Peter