南阳理工网站建设,建设网站的岗位职责,深圳app开发价格,做家装的网站有什么不同在 linux下可以通过查看 cat /proc/cpuinfo查看CPU的相关信息#xff0c;但是在linux下C编程需要使用汇编语言来实现#xff0c;因为C语言中没有实现查看CPU信息的函数#xff0c;一般实现如下#xff1a;(C中运行汇编用 __asm__等)#include#includestatic inline voidget_…在 linux下可以通过查看 cat /proc/cpuinfo查看CPU的相关信息但是在linux下C编程需要使用汇编语言来实现因为C语言中没有实现查看CPU信息的函数一般实现如下(C中运行汇编用 __asm__等)#include#includestatic inline voidget_cpuid(unsigned int i, unsigned int * buf){unsigned int eax,ebx,ecx,edx;__asm__ (cpuid:a(eax),b(ebx),c(ecx),d(edx):a(i));buf[0]eax;buf[1]ebx;buf[2]edx;buf[3]ecx;}int main(){unsigned int cpu[4];get_cpuid(0,cpu);}需要清楚的是get_cpuid(i,buf)中i等于不同值代表不同的含义0: Get vendor ID1: Processor Info and Feature Bits,3: Processor Serial Number80000000h: Get Highest Extended Function Supported80000001h: Extended Processor Info and Feature Bits80000002h,80000003h,80000004h: Processor Brand String具体访问http://en.wikipedia.org/wiki/CPUID