开发者

cpu information

开发者 https://www.devze.com 2023-03-01 06:07 出处:网络
I want know how can we find cpu information (N开发者_JS百科umber of cpus and spead of cpu) from c program in linux.

I want know how can we find cpu information (N开发者_JS百科umber of cpus and spead of cpu) from c program in linux. can anybody help me onthat


You can read from the /proc/cpuinfo file to gain information about CPUs in the running computer.


As Delan has mentioned /proc/cpuinfo does provide those details.

There is also sysconf for getting the number of logical CPU's.

long numcpus = sysconf(_SC_NPROCESSORS_ONLN);
printf("Number of CPU's=%ld\n",numcpus);
0

精彩评论

暂无评论...
验证码 换一张
取 消