Re: How do i read the clock cycle counter?

Tuukka Toivonen (tuukkat@ees2.oulu.fi)
Sun, 26 Apr 1998 18:19:23 +0300 (EET DST)


On Fri, 24 Apr 1998, Thomas Jensen wrote:

>I'm using Linux RedHat 5.0 (Kernel 2.0.33), and i have to do some time

I'm using 2.0.33 too, but Slackware one :)

>measurements. How do i read the clock cycle counter register in a
>pentium / Pentium II CPU ??

Here:

----<cut>----
/ Coded by Tuukka Toivonen <tuukkat@ee.oulu.fi> 1997

gcc2_compiled.:
.section .rodata
.LC0:
.string "TSC: %08X%08Xh\n"
.text
.globl main
.type main,@function
main:
rdtsc
pushl %eax
pushl %edx
pushl $.LC0
call printf
xorl %eax,%eax
addl $12,%esp
ret
.Lfe1:
.size main,.Lfe1-main
----<cut>----

Copy and paste this to file "rdtsc.s" and compile with
"gcc rdtsc.s -o rdtsc". It reads and displays cycle
counter in hex.

If you want to use the other MSRs you have to use MSR-patch from
http://fatman.mathematik.tu-muenchen.de/~meyer/msr.html

--
| Tuukka Toivonen <tuukkat@ee.oulu.fi>       [PGP public key
| Homepage: http://www.ee.oulu.fi/~tuukkat/       available]
| Try also finger -l tuukkat@ee.oulu.fi
| Studying information engineering at the University of Oulu
+-----------------------------------------------------------

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