delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/14/16:18:26

Message-ID: <2723E6389F55D311BDC200508B12954701692FD6@pai820exch003u.micro.lucent.com>
From: "Updegrove, Timothy (Tim)" <tupdegrove AT lucent DOT com>
To: "'Zaretskii, Eli'" <eliz AT is DOT elta DOT co DOT il>
Cc: djgpp AT delorie DOT com
Subject: RE: uclock failure at midnight
Date: Wed, 14 Jun 2000 16:18:16 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

I'm running v2.03.  The failure only occurs when booting directly to MS-DOS
(it doesn't 
fail in a dos box under Win98SE).  Here is small test case.  Use the "time"
command to 
set the time 15 seconds or so before midnight and run the test.
=====================================
#include <stdio.h>
#include <time.h>

int delay_clock(unsigned long max_ticks);

int main(int argc, char *argv[]) {

 int status;
 unsigned i;

  for (i=0; i< 20*1000;i++) { //20 sec
    status = delay_clock(1000);
  if (status != 0) {
   printf("Error: delay_clock has failed\n");
   exit(1);
  } // error
 } //for


  return 0;

} // main

int delay_clock(unsigned long max_ticks) {

  unsigned long int
    diff_time;

  uclock_t
    starttime,
    endtime;

  starttime = uclock();
  endtime = starttime;

  diff_time = (unsigned long int) (endtime - starttime);
  while ( diff_time < max_ticks) {
    endtime = uclock();
    diff_time = (unsigned long int) (endtime - starttime);

    if ((diff_time & 0x80000000) == 0x80000000) {
      printf("Error: uclock timer has overflowed.\n");
      printf("       starttime=%08lx, endtime=%08lx, diff_time=%08lx\n",
     (unsigned long int) starttime, (unsigned long int) endtime, diff_time);
      exit(1);
    } // crazy timer
  } /* while delay */

  return 0;
} /* delay_clock */
==================

Eli Zaretskii wrote:

  On Mon, 12 Jun 2000, Tim Updegrove wrote:

  > My program runs 12 seconds but if it tries to run through midnight then
  > it fails because a uclock() value after midnight is less than a uclock()
  > value before midnight.

  `uclock' is written to handle the midnight case, so it should work.
  Please post the shortest test program that can be used to reproduce
  the problem.

  What version of DJGPP is this, btw?  If it's 2.02, please upgrade to
  v2.03 where `uclock' is more reliable on Windows.

  Are you running this on DOS or on Windows?


> ----------
> From: 	Eli Zaretskii[SMTP:eliz AT is DOT elta DOT co DOT il]
> Sent: 	Tuesday, June 13, 2000 6:27 AM
> To: 	Updegrove, Timothy (Tim)
> Cc: 	djgpp AT delorie DOT com
> Subject: 	Re: uclock failure at midnight
> 
> 
> On Mon, 12 Jun 2000, Tim Updegrove wrote:
> 
> > My program runs 12 seconds but if it tries to run through midnight then
> > it fails because a uclock() value after midnight is less than a uclock()
> > value before midnight.
> 
> `uclock' is written to handle the midnight case, so it should work.
> Please post the shortest test program that can be used to reproduce
> the problem.
> 
> What version of DJGPP is this, btw?  If it's 2.02, please upgrade to
> v2.03 where `uclock' is more reliable on Windows.
> 
> Are you running this on DOS or on Windows?
> 

- Raw text -


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