lkml.org 
[lkml]   [1996]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectTime warps with Linux (but only 0.01sec)
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.


\
 
 \ /
  Last update: 2005-03-22 13:37    [from the cache]
©2003-2011 Jasper Spaans