用C在Linux下训练方法:如何获得物理CPU的数量? [英] How to get number of physical CPU:s in Linux using C?
本文介绍了用C在Linux下训练方法:如何获得物理CPU的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
据我所知,的sysconf(_SC_NPROCESSORS_ONLN)
会给我的逻辑处理器的数量。但是,我怎么能得到的物理处理器的数量?
I am aware that sysconf(_SC_NPROCESSORS_ONLN)
will give me the number of logical processors. But how can I get the number of physical processors?
推荐答案
@Havoc病人:
离线CPU都不会在/ proc内/ cpuinfo中。
@Havoc P: offline cpus aren't shown in /proc/cpuinfo .
CPU拓扑是通过/ SYS /设备/系统/ CPU / CPU描述* /拓扑/ *
CPU topology is described by /sys/devices/system/cpu/cpu*/topology/*
这篇关于用C在Linux下训练方法:如何获得物理CPU的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文