From owner-freebsd-hackers Wed Dec 4 10: 7:48 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 8CAA937B404 for ; Wed, 4 Dec 2002 10:07:46 -0800 (PST) Received: from harrier.mail.pas.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0373B43EBE for ; Wed, 4 Dec 2002 10:07:46 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0178.cvx22-bradley.dialup.earthlink.net ([209.179.198.178] helo=mindspring.com) by harrier.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 18Jdvr-0002Ef-00; Wed, 04 Dec 2002 10:07:35 -0800 Message-ID: <3DEE4418.868B4936@mindspring.com> Date: Wed, 04 Dec 2002 10:06:16 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Stijn Hoop Cc: Mike Silbersack , freebsd-hackers@freebsd.org Subject: Re: [nephtes@openface.ca: [Xmame] Use of usleep() with -sleepidle] References: <20021202151816.GJ83264@pcwin002.win.tue.nl> <20021202114019.R31106-100000@patrocles.silby.com> <20021204113154.GA205@pcwin002.win.tue.nl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Stijn Hoop wrote: > On Mon, Dec 02, 2002 at 11:49:03AM -0600, Mike Silbersack wrote: > > 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. > > With the mentioned change of /etc/sysctl.conf to /boot/loader.conf, I am > indeed seeing much better times on this 'benchmark'. See attached log. Not > only the _select_sleep method benefits from this. What are the reasons *not* > to do this? Increased context switch overhead. > > 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. > > And why don't we do the same? (I suspect this is related to the question > above :) Increased context switch overhead. > > To answer your final question: Sleep accuracy doesn't matter to most > > applications, but I'm sure counterexamples could be found. > > Such as emulators :) Actually, for the case you are talking about, your emulator should be using aggregate instead of discrete timeouts, and you would not be having a problem. It's not useful to do 100 1ms timeouts to achieve a 100ms timeout, when you can ask for a single 100ms timeout. I would count this as a bug in your emulator. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message