From: tdu AT enter DOT net (Tim Updegrove) Newsgroups: comp.os.msdos.djgpp Subject: Re: Algorithm for integer timing loop Message-ID: <39207b3e.1189164@news.enter.net> References: X-Newsreader: Forte Free Agent 1.11/32.235 Lines: 73 Date: Mon, 15 May 2000 22:46:08 GMT NNTP-Posting-Host: 207.18.11.119 X-Complaints-To: Abuse Role , We Care X-Trace: monger.newsread.com 958430768 207.18.11.119 (Mon, 15 May 2000 18:46:08 EDT) NNTP-Posting-Date: Mon, 15 May 2000 18:46:08 EDT Organization: ENTER.net (enter.net) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Thank-you for asking for a small test case. In creating it, I found a key piece of info. It only fails after doing a Control+C in a Windows 98 SE (also Win95) and then restarting the program. The 1st time it runs great but after killing it and restarting it, then it fails the very first time. What is Windows doing? Is there a fix? To compile it: gcc -o test.exe test.cpp ================= #include #include int delay_clock(unsigned long max_ticks); int main(int argc, char *argv[]) { unsigned long int i, j; for(j=0; j < 0xffffffff; j++) { for (i=0; i<10000; i++) delay_clock(60); printf("done, %08lx\n", j); } //j 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 */ On Sun, 14 May 2000 10:16:31 +0300 (IDT), Eli Zaretskii wrote: > >On Sat, 13 May 2000, Tim Updegrove wrote: > >> I'm still having negative values (upper 16 bits out of 32 bits become >> 0xffff) with uclock() in Windows 98 SE using version 2.03. > >Please post a short test program that exhibits this problem, the command >lines used to compile it and run it, anbd its output on your system.