Mail Archives: djgpp/2000/05/03/22:09:21
Now that I've checked the archives once my lovely wife was off the
phone, I see uclock() has a problem in the 1st 55ms. The 281 version
is probably the compiler version and not the DJGPP version. Okay, I
found it. I have DJGPP version 2.02. Is this problem fixed in a
later version? Thank-you for your help again (and your patience)..
On Thu, 04 May 2000 01:30:38 GMT, tdu AT enter DOT net (Tim Updegrove) wrote:
>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 -