Doug Fortune wrote:
> Does anyone have a C code snippet to read the
> high resolution Pentium timer? I am presuming
> it is 64 bits.
>
> Thanks
>
> -- [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/
Can't remember where I got this, or how well it works. It's supposed to
return the number of ns.
I think you need to muck with the CPUCLK_PERIOD value depending on
you're CPU's clock speed.
#define CPUCLK_PERIOD 2
#define __NAME_STRING(x) #x
#define NAME_STRING(x) __NAME_STRING(x)
#define rt_get_nstime(llptr) \
__asm__ __volatile__ ( \
"xor %%eax, %%eax\n\t" \
"cpuid \n\t" \
"rdtsc \n\t" \
"movl %%eax, %%ebx \n\t"\
"movl %%edx, %%eax \n\t"\
"movl $"NAME_STRING(CPUCLK_PERIOD)", %%ecx \n\t"\
"mull %%ecx \n\t"\
"movl %%eax,%%edx \n\t"\
"movl %%ebx,%%eax \n\t" \
"movl %%edx,%%ebx \n\t" \
"mull %%ecx \n\t"\
"addl %%ebx,%%edx \n\t"\
: "=A" (llptr) \
: : "eax","ebx","ecx","edx","memory")
-- [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/