Re: How do i read the clock cycle counter?

Paul Flinders (paul@dawa.demon.co.uk)
27 Apr 1998 21:17:43 +0100


Thomas Jensen <kauf@cs.auc.dk> writes:

> Hi!
>
> I'm using Linux RedHat 5.0 (Kernel 2.0.33), and i have to do some time
> measurements. How do i read the clock cycle counter register in a
> pentium / Pentium II CPU ??
>
> Thomas Kaufmann Jensen / kauf@cs.auc.dk
>
> .
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu

unsigned int count[2];
asm("rdtsc"
:"=a" (count[0]),
"=d" (count[1]));

Should do it, you need a gas recent enough to understabd the rdtsc
opcode. If not there's an example somewhere in the kernel code which
uses the opcodes.

-- 
Paul

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu