Mail Archives: djgpp/1999/08/12/21:05:18
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
> Let me guess: you are running this on Windows 9X, right?
>
> If so, then the problem is that `uclock' reprograms the system timer when
> you call it the first time, and Windows does not update the actual timer
> device with the new mode until the next timer tick. So, during the first
> timer tick interval after the first call to `uclock', the timer still
> works in its original mode, before it was reprogrammed, and confuses the
> computations inside `uclock'.
>
> In DJGPP v2.03, `uclock' was changed to wait until the timer ticks when
> it is called for the first time. This solves the problem. As a
> work-around, you can do the same in your code, like this:
>
> int otics;
> uclock ();
> _farsetsel(_dos_ds);
> otics = _farnspeekl(0x46c);
> do {
> errno = 0;
> __dpmi_yield(); /* will set errno to ENOSYS on plain DOS */
> } while (errno == 0 && _farnspeekl(0x46c) == otics);
>
> uclock ();
The following code seems to work fine on W95 :
uclock(); /* Initialise the timer */
while(clock() == 0); /* Wait for first tick */
while(!(kbhit())) /* Loop until keypress */
printf("%Ld\n", uclock());
--
george
- Raw text -