* better real time clock resolution on Alpha?
@ 1994-07-14 18:46 Peter A Krauss
1994-07-18 8:27 ` Sebastian Schmidt
0 siblings, 1 reply; 2+ messages in thread
From: Peter A Krauss @ 1994-07-14 18:46 UTC (permalink / raw)
How do I obtain a better real time clock resolution
than 976 usec on a Alpha?
Consider this program:
-----------------------------------------------------
#include <sys/time.h>
#define N 300
void main(void)
{
int i;
struct timeval t[N];
for (i= 0; i < N; i++)
gettimeofday(&(t[i]), NULL);
for (i= 1; i < N; i++)
printf("%3d: %d.%06d diff: %d\n", i,
t[i].tv_sec, t[i].tv_usec,
t[i].tv_usec - t[i - 1].tv_usec);
}
-----------------------------------------------------
...
175: 774211062.325008 diff: 0
176: 774211062.325008 diff: 0
177: 774211062.325008 diff: 0
178: 774211062.325008 diff: 0
179: 774211062.325008 diff: 0
180: 774211062.325984 diff: 976
181: 774211062.325984 diff: 0
182: 774211062.325984 diff: 0
183: 774211062.325984 diff: 0
184: 774211062.325984 diff: 0
185: 774211062.325984 diff: 0
...
-----------------------------------------------------
I get many times the same value, and after 976 usec
the clock advances to the next value.
Is there any system call to obtain a better time resolution?
mfg Peter
--
Peter A. Krauss Peter.A.Krauss@regent.e-technik.tu-muenchen.de
Lehrstuhl fuer Institute of
Rechnergestuetztes Entwerfen Electronic Design Automation
Technische Universitaet Muenchen Technical University of Munich, Germany
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: better real time clock resolution on Alpha?
1994-07-14 18:46 better real time clock resolution on Alpha? Peter A Krauss
@ 1994-07-18 8:27 ` Sebastian Schmidt
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Schmidt @ 1994-07-18 8:27 UTC (permalink / raw)
In article <30416i$5lo@rebold.regent.e-technik.tu-muenchen.de>, pak@regent.e-technik.tu-muenchen.de (Peter A Krauss) writes:
>
> How do I obtain a better real time clock resolution
> than 976 usec on a Alpha?
>
The highest resolution you get by using the process cycle counter (PCC),
which runs with a fraction from N=1..16 of the CPU clock. For the
21064 N is 1. For more information see pg. (I) 4-118 of the Alpha
Architecture Reference Manual. Here is a little example, I use to time
short code sequences (using the extended asm features of GCC):
register unsigned long start, stop;
unsigned time;
asm ("rpcc %0" : "=r" (start));
/* insert the instructions you want to time here */
asm ("rpcc %0" : "=r" (stop));
time= (stop&0xffffffff)-(start&0xffffffff);
--
May your disk buffers flush before powerdown!
Sebastian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1994-07-18 8:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-07-14 18:46 better real time clock resolution on Alpha? Peter A Krauss
1994-07-18 8:27 ` Sebastian Schmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox