Time warps with Linux (but only 0.01sec)

Wolfram Gloger (Wolfram.Gloger@dent.med.uni-muenchen.de)
Tue, 30 Apr 1996 01:38:50 +0200


Hi,

There was some talk about the pentium do_fast_gettimeoffset() routine
lately, and claimed that the timer would progress monotonously. Well,
it does not, for me. With the following program

#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>

int main()
{
struct timeval t, t_old;
long i;

timerclear(&t);
for(i=0; i<100000000l; i++) {
gettimeofday(&t, NULL);
if(i>0 && t.tv_sec==t_old.tv_sec && t.tv_usec<t_old.tv_usec)
printf("old=%d new=%d\n", t_old.tv_usec, t.tv_usec);
t_old = t;
}
}

I get:

old=333624 new=323878
old=343739 new=333872
old=673699 new=663860
old=163717 new=153859
old=963688 new=953864
old=183655 new=173884
old=463701 new=453857
...

As you can see, very rarely (mostly during heavy disk activity), but
consistently with a difference of 0.01sec. Looking at the kernel
source, I can't see how this can happen.

Thanks,
Wolfram.