From owner-freebsd-hackers Mon Dec 2 9:42: 5 2002 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 A1D4437B401 for ; Mon, 2 Dec 2002 09:42:03 -0800 (PST) Received: from out7.mx.nwbl.wi.voyager.net (out7.mx.nwbl.wi.voyager.net [169.207.3.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id 337D043EC5 for ; Mon, 2 Dec 2002 09:42:03 -0800 (PST) (envelope-from silby@silby.com) Received: from [10.1.1.6] (d84.as29.nwbl0.wi.voyager.net [169.207.73.84]) by out7.mx.nwbl.wi.voyager.net (Postfix) with ESMTP id 81BC9930A8; Mon, 2 Dec 2002 11:41:57 -0600 (CST) Date: Mon, 2 Dec 2002 11:49:03 -0600 (CST) From: Mike Silbersack To: Stijn Hoop Cc: freebsd-hackers@freebsd.org Subject: Re: [nephtes@openface.ca: [Xmame] Use of usleep() with -sleepidle] In-Reply-To: <20021202151816.GJ83264@pcwin002.win.tue.nl> Message-ID: <20021202114019.R31106-100000@patrocles.silby.com> References: <20021202151816.GJ83264@pcwin002.win.tue.nl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 2 Dec 2002, Stijn Hoop wrote: > Hi, > > Summary: this is going to be a rather long email about the timing of various > _sleep functions, compared to the same on Linux. > > I ran across this at the xmame mailing list, and I have seen some > interesting results. > One had an Athlon 1400XP, and got the following for the select speeds: > > %%% > Testing _select_sleep (x 1000), delay 8 > Total time: 9999.906000 ms; unit time: 9.999906 ms; estimated overhead: 1.999906 ms > %%% > What's going on here? Is our select really that much slower, or is the program > measuring the wrong values, or doesn't this speed make a difference in > 'real-world' applications, or what? > > --Stijn The time select() takes should be directly related to your system's hz setting. The default for FreeBSD is 100, which means that the interrupt timer will fire every 10ms. If you want to play with that, edit /etc/sysctl.conf and set kern.hz="1000", which should give you 1 ms accuracy. As to why Linux may appear "better"... I believe that Linux defaults to hz=100, but that the default switched to hz=1000 sometime in the recent past. To answer your final question: Sleep accuracy doesn't matter to most applications, but I'm sure counterexamples could be found. Mike "Silby" Silbersack To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message