access to model specific registers, IA32_APERF / IA32_MPERF, to measure actual CPU frequency

As far as I understand to measure the actual operating CPU frequency I need access to the model specific registers (MSR) IA32_APERF and IA32_MPERF (Assembly CPU frequency measuring algorithm).

However, access to the MSR registers is privileged (through the rdmsr instruction). Is there another way this can be done? I mean, for example, through a device driver/library which I could call in my code. It seems strange to me that reading the registers is privileged. I would think only writing to them would be privileged.

Note: the rdtsc instruction does not account for turbo boost and thus cannot report the actual operating frequency

Edit: I'm interested in solutions for Linux and/or Windows.

Answers


  1. You are right, the proper way to find average cpu frequency described in 2nd answer in your link.

  2. To read msrs on linux you can use tool RDMSR.

  3. The only thing that maybe missleading in that answer, is maxfrequency. It should be not maxfrequency, but nominal frequency (max non-turbo frequency), as MPERF counter counts in max-non turbo frequency. You can get this frequency from MSR 0xCE bits 8:15 (ref)


Need Your Help

Loading a jar at runtime causes a NoClassDefFoundError/ClassNotFoundException

java jar dependencies runtime classloader

Summary: Loading a jar from a running Java program causes a NoClassDefFoundError caused by a ClassNotFoundException caused by inter-class dependencies (e.g. import statements). How can I get around...

Passing Parameters (Novice) (Java)

java parameter-passing pass-by-value

I'm fairly beginner when it comes to Java, as I've focused more on Js for University rather than the OOP-heavy brother of it and as a result, I can't quite pass my parameters properly.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.