lkml.org 
[lkml]   [1998]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: How do i read the clock cycle counter?
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

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.296 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site