Subject: Re: microtime going backwards
To: None <port-i386@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: port-i386
Date: 07/31/2002 16:36:35
On Tue, Jul 30, 2002 at 06:45:59PM +0100, David Laight wrote:
> I've added some diagnostics to the end of (my) microtime()
> code to detect time travel.
> 
> microtime leapt back to 3d46cc10:44307 (+2457) from 3d46cc10:44326 (+2476)

I now suspect that this is actually caused by a 'bug' in my check :-(
If microtime() is called from an ISR that interrupts the function
called with interrupts enabled, then the two calls exit in the
reverse order to that in which they worked out the time.
Unfortunately I don't seem to be able to reproduce my own test
at the moment.

OTOH microtime uses a cli and sti pair to disable interrupts
- which might erronously enable interrupts (pushf; cli ... popf
is safer).  Also it doesn't work with timer chips with broken
latches.

	David

-- 
David Laight: david@l8s.co.uk