www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/24/23:58:52

From: Raul Kompass <kompass AT server1 DOT rz DOT uni-leipzig DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: PC Time
Date: Mon, 23 Sep 1996 13:57:48 -0700
Organization: University Leipzig
Lines: 52
Message-ID: <3246F9CC.40FD@server1.rz.uni-leipzig.de>
References: <Pine DOT SUN DOT 3 DOT 95 DOT 960922200128 DOT 857C-100000 AT conan DOT ids DOT net>
Reply-To: kompass AT server1 DOT rz DOT uni-leipzig DOT de
NNTP-Posting-Host: kogn5.psychologie.uni-leipzig.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019