Subject: Re: questions about port and timer functions
From: [email-masked] (Patrick J. Fay)

18 Jan 1998 22:31:50 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: Benjamin Riefenstahl <[email-masked]>
Cc: [email-masked]

On Fri, 16 Jan 1998, Benjamin Riefenstahl wrote:

> Hi Armin,
> 
> 
> [email-masked] 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 ([email-masked])
> Crocodial Communications EntwicklungsGmbH
> Ophagen 16a, D-20257 Hamburg, Germany
> -
> For help on using this list (especially unsubscribing), send a message to
> "[email-masked]" with one line of text: "help".
> 

Patrick Fay, Ph.D., Intel Corp.            email:   [email-masked]
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
"[email-masked]" with one line of text: "help".