Here's a complete program to extract and print the
current 64 bit pentium timer value.
Many thanks to Andris Pavenis <[EMAIL PROTECTED]>
who forwarded the essential assembly routine.
- Doug
//gcc pentiumtimer.c -o pentiumtimer -O2 ; ./pentiumtimer
#include <stdio.h>
#ifndef __RDTSC_H
#define __RDTSC_H
inline long long rdtsc(void)
{
union { long L[2]; long long LL; } W;
asm __volatile__ (".byte 0x0F,0x31" : "=a"(W.L[0]), "=d"(W.L[1]));
return W.LL;
}
#endif
main()
{
unsigned long prev = 0L;
union { unsigned long L[2];
unsigned long long LL;
}X;
X.LL = rdtsc();
printf("cnt %u %u\n", X.L[1], prev = X.L[0]);
X.LL = rdtsc();
printf("cnt %u %u delta %u\n", X.L[1], X.L[0], X.L[0] - prev );
}
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/