This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: questions about port and timer functions


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]