Mail Archives: djgpp/2000/05/03/21:14:18
From: | tdu AT enter DOT net (Tim Updegrove)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | uclock erratic
|
Message-ID: | <3910c80d.139960@news.enter.net>
|
X-Newsreader: | Forte Free Agent 1.11/32.235
|
Lines: | 53
|
Date: | Thu, 04 May 2000 01:30:38 GMT
|
NNTP-Posting-Host: | 207.16.152.106
|
X-Complaints-To: | Abuse Role <abuse AT enter DOT net>, We Care <abuse AT newsread DOT com>
|
X-Trace: | newshog.newsread.com 957403838 207.16.152.106 (Wed, 03 May 2000 21:30:38 EDT)
|
NNTP-Posting-Date: | Wed, 03 May 2000 21:30:38 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
|
The uclock() function appears to be returning crazy values sometimes.
The returned value seems to have wrapped but the program only runs
less than one minute. The very 1st call to uclock() returns 0 and
subsequent calls return higher values as expected. If uclock() is
being called in a tight loop, the difference between two calls is
about 0xa00. The problem is that sometimes a value like 0xffff0e87
will be returned when the preceding returned value was something like
0x00000be7 (I've made up the lower 16 bits because I don't recall
actual values). The problem is that only a very small amount of time
has elapsed yet the upper 16 bits are all ones when they were
previously all zeros
One last bit of info. The Dell XPS-T500 (P3 500 Mhz) machine is
booted to MS-DOS and the program is run. The DJGPP version is 281 (I
think).
Am I doing something stupid? Has anyone else experienced this
problem? Any help would be much appreciated.
I've included the below function that uses uclock(). The program
stops because bit 31 is set in diff_time. The display shows the upper
16 bits are set in diff_time and endtime.
#include <time.h> // needed for uclock()
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/will overflow\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 */
- Raw text -