欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

查看系统cpu相关信息

程序员文章站 2022-04-19 11:22:24
Linux系统下查看:查看cpu的型号信息:cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c查看物理cpu个数:grep "physical id" /proc/cpuinfo | sort | uniq | wc -l查看每个物理cpu的核心数:grep 'cpu cores' /proc/cpuinfo | uniq | awk -F':' '{print $2}'查看cpu的线程数:grep 'processor' /proc/...

Linux系统下查看:

查看cpu的型号信息:
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
查看物理cpu个数:
grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
查看每个物理cpu的核心数:
grep 'cpu cores' /proc/cpuinfo | uniq | awk -F':' '{print $2}'
查看cpu的线程数:
grep 'processor' /proc/cpuinfo | sort | wc -l

例:

# 查看cpu的型号信息
[root@*** ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      Intel(R) Xeon(R) Gold 6230 CPU @ 2.10GHz
      
# 有2个物理cpu
[root@*** ~]# grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
2

# 每个物理cpu有20个核心
[root@*** ~]# grep 'cpu cores' /proc/cpuinfo | uniq | awk -F':' '{print $2}'
 20
 
 # cpu的总线程数
 [root@*** ~]# grep 'processor' /proc/cpuinfo | sort | wc -l
80

由上面的信息可以得出该服务器的cpu信息如下:
cpu型: Intel® Xeon® Gold 6230 CPU @ 2.10GHz
物理cpu个数:2
每个cpu核心数:20
cpu总线程数:80

共有2个cpu,每个cpu20个核心,每个核心2个线程,共80线程。

同时也可以使用dmidecode 查看cpu信息

[root@*** ~]# dmidecode -h
Usage: dmidecode [OPTIONS]
Options are:
 -d, --dev-mem FILE     Read memory from device FILE (default: /dev/mem)
 -h, --help             Display this help text and exit
 -q, --quiet            Less verbose output
 -s, --string KEYWORD   Only display the value of the given DMI string
 -t, --type TYPE        Only display the entries of given type
 -u, --dump             Do not decode the entries
     --dump-bin FILE    Dump the DMI data to a binary file
     --from-dump FILE   Read the DMI data from a binary file
     --no-sysfs         Do not attempt to read DMI data from sysfs files
 -V, --version          Display the version and exit

# 使用-t参数获取支持的字段
[root@*** ~]# dmidecode -t
dmidecode: option requires an argument -- 't'
Type number or keyword expected
Valid type keywords are:
  bios
  system
  baseboard
  chassis
  processor
  memory
  cache
  connector
  slot

例:
想获取cpu的核心数:

# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.0 are not
# fully supported by this version of dmidecode.
....
	Core Count: 20
	Core Enabled: 20
	Thread Count: 40
	...
	Core Count: 20
	Core Enabled: 20
	Thread Count: 40

查看内存信息:


[root@***  ~]# dmidecode -t memory
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.0 are not
# fully supported by this version of dmidecode.

Handle 0x1000, DMI type 16, 23 bytes
Physical Memory Array
...

Handle 0x1100, DMI type 17, 84 bytes
...

Windows系统下查看:
打开任务管理器---->性能
查看系统cpu相关信息
这台windows机器有1个物理cpu,2个核心,每个核心2个线程,总计4个线程。

对于cpu来说,线程数总是大于或等于核心数的,一个核心最少对应一个线程,但通过超线技术,一个核心可以对应两个线程,也就是可以同时运行两个线程。

CPU线程数概念仅针对Intel的cpu才有用,因为是通过Intel超线程技术实现。而AMD的cpu,只有核心数的概念,没有线程数的概念。

本文地址:https://blog.csdn.net/weixin_48351036/article/details/112553309

相关标签: 系统