Skip to contentSkip to conversation

GPS Leap Second Scheduled!

DISCUSSION Ethan O'Connor 1 participant 1 message Sep 11, 1998

lore
Share & tools
lore
#0 lore raw
Quoted 17 lines · Roger Wolff
Quoted 9 lines · Chris Wedgwood
Quoted 2 lines · Colin Plumb

- gettimeofday() never returns the same value twice (documented BSD behaviour)

Ouch... gettimeofday(2) only presently has usec resolution. I suspect we can make this report the same value twice on really high end boxes (667MHz Alpha maybe, 400Mhz Sparcs?), if not now, in a year or so. Even a P.ii 600 or so can probably manage it.

This is defined behaviour. On processors where gettimeofday can be called more than once in a microsecond (SMP systems, and fast systems), the kernel is required to keep a last-time-returned, and increment it and return that if the value calculated is below the stored value.

Quoted 6 lines

If you have the results from two gettimeofday calls, you can always subtract them and divide by the result without checking for zero. That's what the spec says.

A kernel will get into trouble if you keep on calling gettimeofday more than a million times a second.....

Modifying Chris's code to call gettimeofday() 4 times the second time around and to print the usec values for the four successive calls yields the following on this system (SunOS 5.6, Ultra-IIi/333Mhz):

athena% a.out
213426
213426
213426
213427
athena% a.out
499126
499126
499127
499127

and even:

athena% a.out
947875
947875
947875
947875

Etc...

FWIW.

-Ethan O'Connor
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/faq.html