在c语言中如何取得cpuid

在c语言中如何取得cpuid,第1张

#include<stdioh>

#include<stdlibh>

#include<timeh>

int main()

{

srand(time(0));

for(int i=0;i<10;i++)

printf("%3d",rand()%100+1);

printf("\n");

return 0;

}

生成10个1-100的随机整数。

建议你去看看是驱动开发论坛。关键不是C语言还是汇编语言。这个东西应该有相关手册的,要实现估计要用DDK。

假如是在找不到手册,那就只能考虑把CPUCOOL的驱动逆向工程了,找找线索了。

建议楼主以后不要到baidu来问开发类问题,楼上除了一楼还像样,都是超级菜鸟。到CSDN上问问吧。

祝你好运。

如果是获取 cpu 时钟 的 tick:

clock_t tick1,tick2;

tick1=clock(); // 开机到执行这句时的毫秒数 ms

等待一会

tick2=clock(); // 开机到执行这句时的毫秒数 ms

dt = (double) (tick2 - tick1); // 或得时间差。

===============

如果是 获取 CPU cycle count

#include <stdinth>

// Windows

#ifdef _WIN32

#include <intrinh>

uint64_t rdtsc(){

return __rdtsc();

}

// Linux/GCC

#else

uint64_t rdtsc(){

unsigned int lo,hi;

__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));

return ((uint64_t)hi << 32) | lo;

}

#endif

===================

获取高精度时间(MS VC++ 60编译器):

// Pentium instruction "Read Time Stamp Counter"

__forceinline unsigned _int64 My_clock(void)

{

_asm _emit 0x0F

_asm _emit 0x31

}

unsigned _int64 Start(void) { return My_clock();}

unsigned _int64 Stop(unsigned _int64 m_start, unsigned _int64 m_overhead)

{return My_clock()-m_start - m_overhead; }

==========

获取cpu 速度(MS VC++ 60编译器):

void get_CPU_speed()

{

unsigned _int64 m_start=0, m_overhead=0;

unsigned int CPUSpeedMHz;

m_start = My_clock();

m_overhead = My_clock() - m_start - m_overhead;

printf("overhead for calling My_clock=%I64d\n", m_overhead);

m_start = My_clock();

wait_ms(2000);

CPUSpeedMHz=(unsigned int) ( (My_clock()- m_start - m_overhead) / 2000000);

printf("CPU_Speed_MHz: %u\n",CPUSpeedMHz);

}

以上就是关于在c语言中如何取得cpuid全部的内容,包括:在c语言中如何取得cpuid、如何用C语言获取电脑CPU,显卡等温度信息、C语言获取CPU tick等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9523873.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存