delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/04/13/03:26:12

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Philip Aston" <philipa AT mail DOT com>
MIME-Version: 1.0
Message-ID: <15561.26590.782158.717023@lineone.net>
Date: Fri, 26 Apr 2002 15:44:46 +0100
To: cygwin AT cygwin DOT com
Subject: 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019