Linux上如何查看物理CPU個數,核心數,線程數,linux個數

來源:互聯網
上載者:User

Linux上如何查看物理CPU個數,核心數,線程數,linux個數

首先,看看什麼是超執行緒概念

超執行緒技術就是利用特殊的硬體指令,把兩個邏輯核心類比成兩個物理晶片,讓單個處理器都能使用線程級並行計算,進而相容多線程作業系統和軟體,減少了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    : 0physical 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.10GHzIntel(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.

 

參考:

1. http://www.differencebetween.com/difference-between-core-and-vs-processor/

2. http://jingyan.baidu.com/article/63acb44a81001361fcc17e21.html



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.