日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux上如何查看物理CPU个数,核数,线程数

發布時間:2025/3/21 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux上如何查看物理CPU个数,核数,线程数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

首先,看看什么是超線程概念

超線程技術就是利用特殊的硬件指令,把兩個邏輯內核模擬成兩個物理芯片,讓單個處理器都能使用線程級并行計算,進而兼容多線程操作系統和軟件,減少了CPU的閑置時間,提高的CPU的運行效率。
超線程技術是在一顆CPU同時執行多個程序而共同分享一顆CPU內的資源,理論上要像兩顆CPU一樣在同一時間執行兩個線程,雖然采用超線程技術能同時執行兩個線程,但它并不象兩個真正的CPU那樣,每個CPU都具有獨立的資源。當兩個線程都同時需要某一個資源時,其中一個要暫時停止,并讓出資源,直到這些資源閑置后才能繼續。因此超線程的性能并不等于兩顆CPU的性能。

?

其次,看看物理CPU個數,核數以及線程數的關系

總核數 = 物理CPU個數 * 每顆物理CPU的核數
總邏輯CPU數 = 物理CPU個數 * 每顆物理CPU的核數 * 超線程數

上述公式中,邏輯CPU數即線程數

?

如何查看CPU物理個數

# grep 'physical id' /proc/cpuinfo | sort -u

physical id : 0 physical id : 1

?

如何查看每個物理CPU的核數

# grep 'core id' /proc/cpuinfo | sort -u | wc -l

8

?

如何查看總的邏輯CPU個數

# grep 'processor' /proc/cpuinfo | sort -u | wc -l

32

32/8/2=2,可見該CPU支持并已打開超線程。

?

如何查看CPU的型號

# dmidecode -s processor-version

Intel(R) Xeon(R) CPU E5-2658 @ 2.10GHz Intel(R) Xeon(R) CPU E5-2658 @ 2.10GHz

?

關于物理CPU,核數以及超線程的區別

A core is the most basic computational unit of a processor. A processor is made up of one or more cores. Tradition processors had only one core while modern processors have multiple cores.

A core consists of an ALU, CU, and a set of registers.

A core consists of two levels of caches called L1 and L2 which is there in each core.

A processor consists of a cache that is shared by call cores called L3 cache. It is common to all cores.

A processor depending on the architecture can consist of a memory controller and an input/output controller.

Certain processor packages consist of Graphics Processing Units (GPU) as well.

A core that does not have hyper-threading can execute only one instruction at a time while a multicore processor made up of several cores can execute several instructions parallel. If a processor is made up of 4 cores that do not support hyper threading then that processor can execute 4 instructions at the same time.

A core having hyper-threading technology has redundant functional units so that they can execute multiple instructions at a time. For example, a core with 2 threads can execute 2 instructions at the same time hence a processor with 4 such cores can execute 2×4 instructions parallel. These threads are usually called logical cores and the task manager of Windows generally show the number of logical cores but not the physical cores.

轉載于:https://www.cnblogs.com/xiaojianblogs/p/6209382.html

總結

以上是生活随笔為你收集整理的Linux上如何查看物理CPU个数,核数,线程数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。