Linux查看系统cpu个数、核心数、线程数
在Linux系統(tǒng)中,如何詳細(xì)了解CPU的信息呢? 當(dāng)然是通過(guò)cat /proc/cpuinfo來(lái)檢查了,但是比如幾個(gè)物理CPU/幾核/幾線程,這些問(wèn)題怎么確定呢?
經(jīng)過(guò)查看,我的開(kāi)發(fā)機(jī)器是1個(gè)物理CPU,4核8線程,Intel(R) Core(TM) i7 CPU 860? @ 2.80GHz
記錄一下,判斷的過(guò)程和知識(shí)。
判斷依據(jù):
1.具有相同core id的cpu是同一個(gè)core的超線程。
2.具有相同physical id的cpu是同一顆cpu封裝的線程或者cores。
英文版:
1.Physical id and core id are not necessarily consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.
2.Any cpu with the same physical id are threads or cores in the same physical socket.
echo "logical CPU number:"
邏輯CPU個(gè)數(shù)
cat /proc/cpuinfo | grep "processor" | wc -l
echo "physical CPU number:"
物理CPU個(gè)數(shù):
cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -lecho "core number in a physical CPU:"
每個(gè)物理CPU中Core的個(gè)數(shù):
cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'查看每個(gè)physical cpu上core id的數(shù)量,即為每個(gè)物理CPU上的core的個(gè)數(shù)
cat /proc/cpuinfo | grep "core id"#是否為超線程?
#如果有兩個(gè)邏輯CPU具有相同的”core id”,那么超線程是打開(kāi)的。
?
每個(gè)物理CPU中邏輯CPU(可能是core, threads或both)的個(gè)數(shù):
cat /proc/cpuinfo | grep "siblings"/proc/cpuinfo 文件包含系統(tǒng)上每個(gè)處理器的數(shù)據(jù)段落。/proc/cpuinfo 描述中有 6 個(gè)條目適用于多內(nèi)核和超線程(HT)技術(shù)檢查:processor, vendor id, physical id, siblings, core id 和 cpu cores。
processor 條目包括這一邏輯處理器的唯一標(biāo)識(shí)符。
physical id 條目包括每個(gè)物理封裝的唯一標(biāo)識(shí)符。
core id 條目保存每個(gè)內(nèi)核的唯一標(biāo)識(shí)符。
siblings 條目列出了位于相同物理封裝中的邏輯處理器的數(shù)量。
cpu cores 條目包含位于相同物理封裝中的內(nèi)核數(shù)量。
如果處理器為英特爾處理器,則 vendor id 條目中的字符串是 GenuineIntel。
判斷CPU是否64位,檢查cpuinfo中的flags區(qū)段,看是否有l(wèi)m標(biāo)識(shí)。
Are the processors 64-bit?
A 64-bit processor will have lm ("long mode") in the flags section of cpuinfo. A 32-bit processor will not.
總結(jié)
以上是生活随笔為你收集整理的Linux查看系统cpu个数、核心数、线程数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [转] Java @interface
- 下一篇: nodejs-url网址解析的好帮手