Re: Avoiding microtime(9) global state
Jason Thorpe <[email protected]> Wed, 30 Jun 2004 18:09:05 -0700
| Newsgroups | gmane.os.netbsd.devel.smp |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
PGP.sig
(application/pgp-signature, 186 B) - not displayed