Subject: Re: Avoiding microtime(9) global state
To: Martin Husemann <martin@duskware.de>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-smp
Date: 06/30/2004 18:09:05
--Apple-Mail-14-815279607
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed


On Jun 30, 2004, at 1:51 PM, Martin Husemann wrote:

> On Wed, Jun 30, 2004 at 01:19:44PM -0700, Erik E. Fair wrote:
>> NetBSD should provide both facilities (ToD & interval time), and the
>> code we write needs to be clear about which it is using and why.
>
> My theory is, given a modern CPU with cycle counters
>
>  - accessing the RTC is expensive (and needs locking)
>  - accessing the cycle counters is ~free (and per cpu, most likely 
> atomic)

Note, for the current cycle-counter based microtime(), we do not access 
the RTC.  What we do is take the "last time" (time variable), and 
figure out how many microseconds have gone by since we last updated 
that variable, using the cycle counters (whose rates are kept in sync 
using an inter-processor interrupt).

What is the point of having microtime() or any microtime()-like call if 
the call's value is meaningless?  That's what you're proposing.

         -- Jason R. Thorpe <thorpej@wasabisystems.com>


--Apple-Mail-14-815279607
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFA42QxOpVKkaBm8XkRArKbAJwI7HUkpAfr8CE/tbTxh+F7or4+vgCffK5/
sv2mb332LHEnFj7Rowj3ZiU=
=Vc5e
-----END PGP SIGNATURE-----

--Apple-Mail-14-815279607--