From: pfay@acl.lanl.gov (Patrick J. Fay)
Subject: Re: questions about port and timer functions
18 Jan 1998 22:31:50 -0800
Message-ID: <Pine.SGI.3.96.980117215840.4623A-100000.cygnus.gnu-win32@bluemountain.acl.lanl.gov>
References: <34BF3CCA.3FFB67FC@crocodial.de>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: Benjamin Riefenstahl <benny@crocodial.de>
Cc: gnu-win32@cygnus.com

On Fri, 16 Jan 1998, Benjamin Riefenstahl wrote:

> Hi Armin,
> 
> 
> herzer@rz-nov5.rz.fh-weingarten.de wrote:
> > I have written a data acquisation program with DJGPP. Now I want to
....snip...
> 
> Look at the Win32 multimedia timers. They are the only thing that
> actually comes near that precision. The standard Win32 functions like
> GetSystemTime() have the resolution but not the actual granularity.
The routine below will time to the clock tick level (at least on
a pentium pro). Note that you have to put in the clock frequency.
rdtsc returns the hardware clock ticks as an 8 byte integer. 
dclock converts the clock ticks to double precision seconds.
To compile 'gcc tst.c -o tstc'

/* begin tst.c  */
#include <stdio.h>

long long rdtsc(void)
{
asm(    "rdtsc");
}
double dclock(void)
{
  double dtime;
  static double rfrequency=1.0/200e6;
  long long tsc;
  tsc = rdtsc( );
  dtime = tsc * rfrequency;
  return( dtime );
}


int main()
{
    double mytim;
	double t1,t2;
	t1=dclock();
	while(dclock()-t1<10.0){;}
	t2=dclock();
	printf("did we go 10 secs? time=%f\n",t2-t1);
	return 0;
}
/* end tst.c  */
Pat

> 
> 
> so long, benny
> ======================================
> Benjamin Riefenstahl (benny@crocodial.de)
> Crocodial Communications EntwicklungsGmbH
> Ophagen 16a, D-20257 Hamburg, Germany
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 

Patrick Fay, Ph.D., Intel Corp.            email:   pfay@co.intel.com
Los Alamos National Lab                    wk:         (505) 665-9141
CTI M.S. B296                              fax:        (505) 667-5921
Los Alamos NM 87545    ASCI-RED http://www.acl.lanl.gov/~pfay/teraflop

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
