Otto Moerbeek <[EMAIL PROTECTED]> wrote:
> On Tue, 9 Jan 2007, Stefan Krah wrote:
> 
> > Hello,
> > 
> > it seems that the interval timer is incorrect for a process that is
> > started _after_ a sudden date change. Could someone reproduce this
> > before I report it as a bug? System is OpenBSD 4.0-stable, i386.
> 
> You already reported it. This is a bug. Try this diff from art@

Tested it with several kinds of date changes and things work
as they should. Thanks for the quick fix!


Stefan


> 
>       -Otto
> 
> Index: kern_time.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_time.c,v
> retrieving revision 1.60
> diff -u -r1.60 kern_time.c
> --- kern_time.c       30 Oct 2006 20:19:33 -0000      1.60
> +++ kern_time.c       9 Jan 2007 16:42:30 -0000
> @@ -550,7 +550,7 @@
>       if (SCARG(uap, which) == ITIMER_REAL) {
>               struct timeval now;
>  
> -             getmicrotime(&now);
> +             getmicrouptime(&now);
>               /*
>                * Convert from absolute to relative time in .it_value
>                * part of real time timer.  If time for real time timer
> 
> > 
> > 
> > Here are the steps (program below):
> > 
> > 
> > # ./timertest                                                               
> >                                      
> > 0  0  600  0
> > 0  0  598  990000
> > 0  0  597  980000
> > 0  0  596  970000
> > 0  0  595  960000
> > ^C
> > # date
> > Tue Jan  9 15:18:23 CET 2007
> > # date 1522
> > Tue Jan  9 15:22:00 CET 2007
> > # 
> > # 
> > # ./timertest 
> > 0  0  389  610000
> > 0  0  388  600000
> > 0  0  387  590000
> > 0  0  386  580000
> > 
> > 
> > timertest.c
> > =======================================================================
> > #include <sys/time.h>
> > 
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <unistd.h>
> > 
> > 
> > int main(void)
> > {
> > 
> >         struct itimerval itimer = {{0, 0}, {600, 0}};
> > 
> > 
> >         if (setitimer(ITIMER_REAL, &itimer, (struct itimerval *)NULL)) {
> >                 puts("setting itimer failed\n");
> >                 exit(1);
> >         }
> > 
> >         while (1) {
> >                 getitimer(ITIMER_REAL, &itimer);
> >                 printf( "%ld  %ld  %ld  %ld\n", itimer.it_interval.tv_sec,
> >                          itimer.it_interval.tv_usec, itimer.it_value.tv_sec,
> >                          itimer.it_value.tv_usec );
> >                 sleep(1);
> >         }
> > 
> >         return 0;
> > }
> > =======================================================================
> > 
> > 
> > Stefan Krah

Reply via email to