This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gettime time travels after suspend




I have a running process which prints out the result of gettimeofday()
at regular intervals. If I suspend and resume my machine then the
value returned by gettimeofday() is incorrect - it jumps several days
into the future. Doing the same with time() is fine.

I don't want to point fingers, but I suspect the following 1.3.10
change:
 - Use QueryPerformance* functions for gettimeofday calls. (cgf)

Test case below.

Regards,

- Phil



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

int main() {
  struct timeval t;
  time_t t2;
  
  while (1) {
    gettimeofday(&t, 0);
    time(&t2);
    printf("gettimeofday() returns %ld %ld\n", t.tv_sec, t.tv_usec);
    printf("time() returns %ld\n", t2);

    sleep(2);
  }
}

PASTON:philipa% uname -a
CYGWIN_NT-5.0 PASTON 1.3.10(0.51/3/2) 2002-02-25 11:14 i686 unknown
PASTON:philipa% ./gettimeofday-bug
gettimeofday() returns 1018681622 612224
time() returns 1018681623
gettimeofday() returns 1018681624 615154
time() returns 1018681625
gettimeofday() returns 1018681626 618384
time() returns 1018681627
<<< Suspend and resume machine >>>
gettimeofday() returns 1018932412 90805
time() returns 1018681632
gettimeofday() returns 1018932422 917318
time() returns 1018681642
gettimeofday() returns 1018932424 911611
time() returns 1018681644


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]