Roger Wolff wrote:
>Chris Wedgwood wrote:
>> On Wed, Sep 09, 1998 at 02:13:42PM -0600, Colin Plumb wrote:
>> > - 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
>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):
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com