Mobile and Desktop Processors
Intel® Core™ processors, Intel Atom® processors, tools, and utilities
16771 ディスカッション

Is it possible to read temperature information of my 8th gen i7 8700k processor with C++ ?

gomi
ビギナー
3,341件の閲覧回数

Hello,

I Have a Directx11 program which use GPU to draw window and its content. That use winsock2 api to send data on network. My problem is I want to send also processor information on network to see if there is a machine which has temperature problem. Now forget this part, I need to learn if there is a proper way to read this data for this model and how(8th gen i7 8700k). Then, I may try it on a simple command line program with C++.

NOTE: I tried to access a specific register.However, I think results were wrong.

Thank you.

0 件の賞賛
1 解決策
n_scott_pearson
スーパーユーザー
3,322件の閲覧回数

The only guaranteed way to get processor temperatures is via Model-Specific Register (MSR). All other methods (WMI, ACPI) cannot be guaranteed because they are BIOS- and board/system vendor-specific. 

The processor package temperature, if supported, is available via a MSR. The per-Core temperature sensors are also available via a MSR, but the requesting thread needs to be running on a particular core in order to read that core's temperature.

The problem is that MSRs cannot be read in Ring 3. Ring 0 code (i.e. a device driver) is necessary. If you do not want to implement your own device driver, there are examples around that you may be able to get and use, perhaps even in binary form. For example, I believe that the Open Hardware Monitor project has one. The other alternative is to load a tool that includes its own driver and rely upon interfaces offered by this tool. For example, the CoreTemp facility has an API for accessing its sensor data. The Open Hardware Monitor project also exposes all detected sensors into WMI and also provides a DLL for accessing the readings.

Hope this helps,

...S

元の投稿で解決策を見る

2 返答(返信)
n_scott_pearson
スーパーユーザー
3,323件の閲覧回数

The only guaranteed way to get processor temperatures is via Model-Specific Register (MSR). All other methods (WMI, ACPI) cannot be guaranteed because they are BIOS- and board/system vendor-specific. 

The processor package temperature, if supported, is available via a MSR. The per-Core temperature sensors are also available via a MSR, but the requesting thread needs to be running on a particular core in order to read that core's temperature.

The problem is that MSRs cannot be read in Ring 3. Ring 0 code (i.e. a device driver) is necessary. If you do not want to implement your own device driver, there are examples around that you may be able to get and use, perhaps even in binary form. For example, I believe that the Open Hardware Monitor project has one. The other alternative is to load a tool that includes its own driver and rely upon interfaces offered by this tool. For example, the CoreTemp facility has an API for accessing its sensor data. The Open Hardware Monitor project also exposes all detected sensors into WMI and also provides a DLL for accessing the readings.

Hope this helps,

...S

gomi
ビギナー
3,315件の閲覧回数
I have to do this on kernel mode right ? For c++ Windows has ntddk.h for it.
返信