Linux查看CPU及系統信息

FROM: http://hi.baidu.com/yilinghl/blog/item/5b17918b097839d4fc1f103f.html

 

CPU:

more /proc/cpuinfo

-------

文件會顯示cpu的信息
processor 會從0開始記數 繼續下去多個cpu
flags 如果有 ht 說明支持超線程技術
判斷物理CPU的個數可以查看physical id 的值,相同則爲同一個物理 CPU

附:

(超線程技術就是利用特殊的硬件指令,把兩個邏輯內核模擬成兩個物理芯片,讓單個處理器都能使用線程級並行計算,進而兼容多線程操作系統和軟件,減少了CPU的閒置時間,提高的CPU的運行效率。

採用超線程及時可在同一時間裏,應用程序可以使用芯片的不同部分。雖然單線程芯片每秒鐘能夠處理成千上萬條指令,但是在任一時刻只能夠對一條指令進行操作。而超線程技術可以使芯片同時進行多線程處理,使芯片性能得到提升。
超線程技術是在一顆CPU同時執行多個程序而共同分享一顆CPU內的資源,理論上要像兩顆CPU一樣在同一時間執行兩個線程,P4處理器需要多加入一個Logical CPU Pointer(邏輯處理單元)。因此新一代的P4 HT的die的面積比以往的P4增大了5%。而其餘部分如ALU(整數運算單元)、FPU(浮點運算單元)、L2 Cache(二級緩存)則保持不變,這些部分是被分享的。
雖然採用超線程技術能同時執行兩個線程,但它並不象兩個真正的CPU那樣,每個CPU都具有獨立的資源。當兩個線程都同時需要某一個資源時,其中一個要暫時停止,並讓出資源,直到這些資源閒置後才能繼續。因此超線程的性能並不等於兩顆CPU的性能。
英特爾P4 超線程有兩個運行模式,Single Task Mode(單任務模式)及Multi Task Mode(多任務模式),當程序不支持Multi-Processing(多處理器作業)時,系統會停止其中一個邏輯CPU的運行,把資源集中於單個邏輯 CPU中,讓單線程程序不會因其中一個邏輯CPU閒置而減低性能,但由於被停止運行的邏輯CPU還是會等待工作,佔用一定的資源,因此Hyper- Threading CPU運行Single Task Mode程序模式時,有可能達不到不帶超線程功能的CPU性能,但性能差距不會太大。也就是說,當運行單線程運用軟件時,超線程技術甚至會降低系統性能,尤其在多線程操作系統運行單線程軟件時容易出現此問題。
)

___________________

geowang@geowang-desktop:~$ more /proc/cpuinfo 
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model   : 23
model name : Intel(R) Core(TM)2 Quad CPU   Q8200 @ 2.33GHz
stepping : 7
cpu MHz   : 2333.063
cache size : 2048 KB
physical id : 0
siblings : 4
core id   : 0
cpu cores : 4
apicid   : 0
initial apicid : 0
fpu   : yes
fpu_exception : yes
cpuid level : 10
wp   : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall lm constant_ts
c arch_perfmon pebs bts rep_good nopl pni monitor ds_cpl est tm2 ssse3 cx16 xtpr
sse4_1 lahf_lm
bogomips : 4666.12
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model   : 23
model name : Intel(R) Core(TM)2 Quad CPU   Q8200 @ 2.33GHz
stepping : 7
cpu MHz   : 2333.063
cache size : 2048 KB
physical id : 0
siblings : 4
core id   : 1
cpu cores : 4
apicid   : 1
initial apicid : 1
fpu   : yes
fpu_exception : yes
cpuid level : 10
wp   : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall lm constant_tsc arch_perfmon pe
bs bts rep_good nopl pni monitor ds_cpl est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
bogomips : 4666.16
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

processor : 2
vendor_id : GenuineIntel
cpu family : 6
model   : 23
model name : Intel(R) Core(TM)2 Quad CPU   Q8200 @ 2.33GHz
stepping : 7
cpu MHz   : 2333.063
cache size : 2048 KB
physical id : 0
siblings : 4
core id   : 2
cpu cores : 4
apicid   : 2
initial apicid : 2
fpu   : yes
fpu_exception : yes
cpuid level : 10
wp   : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall lm constant_tsc arch_perfmon pe
bs bts rep_good nopl pni monitor ds_cpl est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
bogomips : 4666.18
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

processor : 3
vendor_id : GenuineIntel
cpu family : 6
model   : 23
model name : Intel(R) Core(TM)2 Quad CPU   Q8200 @ 2.33GHz
stepping : 7
cpu MHz   : 2333.063
cache size : 2048 KB
physical id : 0
siblings : 4
core id   : 3
cpu cores : 4
apicid   : 3
initial apicid : 3
fpu   : yes
fpu_exception : yes
cpuid level : 10
wp   : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall lm constant_tsc arch_perfmon pe
bs bts rep_good nopl pni monitor ds_cpl est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
bogomips : 4666.18
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

--------

 

查看系統:

uname -a

一般64的系統都會帶有X86_64 ,而32位的都不帶,一般是i386或者i686等。

geowang@geowang-desktop:~$ uname -a
Linux geowang-desktop 2.6.27-9-server #1 SMP Thu Nov 20 22:56:07 UTC 2008 x86_64 GNU/Linux

 

------------------------

ubuntu系統

方法一

在終端中執行下列指令:

cat /etc/issue

可以查看當前正在運行的 Ubuntu 的版本號。其輸出結果類似下面的內容:

Ubuntu 7.04 /n /l

方法二

使用 lsb_release 命令也可以查看 Ubuntu 的版本號,與方法一相比,內容更爲詳細。執行指令如下:

sudo lsb_release -a

將輸出結果:

Distributor ID: Ubuntu
Description: Ubuntu 7.04
Release: 7.04
Codename: feisty

今天看Ubuntu cookbook的一篇文章,提到如何查看Ubuntude版本,覺得不是很全面,我再來補充和分析一哈子,呵呵!

文章中提到方法一是查看/etc/issue文件中的內容,可以看到版本號。這裏要澄清的一個問題是,/etc/issue的作用主要是在本機登錄時,在登錄提示之前顯示相關的字符信息。/etc/issue.net顯示遠程登錄時的信息。當然一般的提示信息都包含系統版本,但是,如果別人改成自己的個性提示,那就麻煩了。所以我不推薦用這種方法查看系統版本。/etc/issue文件中包含一些換碼符,它們由agetty解釋,所有的換碼符必須緊跟於一個反斜線(/)的後面,比如/d將插入當前時間。

b   插入當前行的波特率
d   插入當前日期
s   插入操作系統的名稱
l   插入當前tty的名稱
m   插入計算機的體系結構id,如i486
n   插入計算機的節點名,即hostname
o   插入計算機的域名
r   插入內核的版本
t   插入當前時間
u   插入當前登陸的用戶數
U   插入1 user 或者 N users,N是當前登陸的用戶數
v   插入當前操作系統的版本


還有一個方法是使用lsb_release命令,個人覺得這種方法比較好。直接看一下怎麼使用這個命令了。查了一下,網上關於這個命令的詳細介紹根本沒有,過兩天我來寫一個好了。

第三種方法是使用uname。uname和lsb_release的區別在於前者主要是顯示系統的整個信息,後者只是顯示版本信息(但是比uname詳細)。直接uanme -a,關於這個命令的介紹很多,就不多說了。

 

 

各種平臺查看cpu信息指令

SUN :

psrinfo -v

/usr/platform/sun4u/sbin/prtdiag

HP-UX :

dmesg | grep processor

top

ioscan -fnC processor

SAM -->; Performance Monitors -->; System Properties -->;

 

AIX:

prtconf

$ lsdev -Cc processor

proc0 Available 00-00 Processor

proc1 Available 00-01 Processor

 

$ lsattr -El proc0

frequency 375000000 Processor Speed False

smt_enabled false Processor SMT enabled False

smt_threads 0 Processor SMT threads False

state enable Processor state False

type PowerPC?_POWER3 Processor type False

Linux:

cat /proc/cpuinfo

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章