Mail Archives: djgpp/1996/09/24/23:58:52
Tom Sgouros wrote:
>
> Can anyone clear up for me the real-time issues on a PC? This is how I
> understand it: There is a clock that ticks 18.2 times a second, and though
> there are functions that provide more precision (e.g. uclock()), they
> are no more accurate. Is this true?
>
> Thanks in advance for any help.
>
> ---------------------------------------------------------------------
> tomss AT ids DOT net - 401-861-2831 - 42 Forge Road, Potowomut, RI 02818 USA
After being told of uclock() by DJ Delorie I changed a program which
measures precision of timing for DJGPP.
You have 0.8 usecs precision of measuring time but there are holes in
your progam-flow due to interrupts.
The following code tells me of ~90 usecs precision for a P75 board.
Interestingly the precision drops to ~160 usecs if I move the mouse
heavily. The precision does not drop with the assembler (Borland-C)
uclock()-version that I posted here last week, instead it reduces then
to ~50 usecs.
#include <time.h>
#include <stdio.h>
long delay_genauigk(long pause) /* Zeit in tics */
{
long first, last, res, tmp;
last = (long)(uclock());
first = last;
res = 0L;
do {
tmp = (long)(uclock());
res =(tmp - last > res) ? tmp - last : res;
last = tmp;
} while (last - first < pause);
return res;
}
int main()
{
long res;
printf("From now...\n");
res = delay_genauigk((long)(10 * UCLOCKS_PER_SEC));
printf("till now 10 seconds should have passed.\n");
printf("The precision of timing is %ld microseconds\n",
(res*1000000)/UCLOCKS_PER_SEC);
return 0;
}
- Raw text -