Subject: Re: Avoiding microtime(9) global state
To: Martin Husemann <>
From: Jason Thorpe <>
List: tech-smp
Date: 06/30/2004 18:09:05
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 <>

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

Version: GnuPG v1.2.3 (Darwin)