如何确定 Windows 和 Linux 下的物理 CPU 数量

war*_*ren 5 windows linux cpu diagnostic

当运行cat /proc/cpuinfo在Linux下,各种信息被踢回。例如:

> cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 15
model name  : Intel(R) Xeon(R) CPU            5130  @ 2.00GHz
stepping    : 6
cpu MHz     : 1995.069
cache size  : 4096 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 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 syscall nx lm constant_tsc pni monitor ds_cpl vmx tm2 cx16 xtpr lahf_lm
bogomips    : 3991.76
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       : 15
model name  : Intel(R) Xeon(R) CPU            5130  @ 2.00GHz
stepping    : 6
cpu MHz     : 1995.069
cache size  : 4096 KB
physical id : 3
siblings    : 2
core id     : 0
cpu cores   : 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 syscall nx lm constant_tsc pni monitor ds_cpl vmx tm2 cx16 xtpr lahf_lm
bogomips    : 3989.46
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
Run Code Online (Sandbox Code Playgroud)

首先,这一切究竟意味着什么?我看到我有一个处理器 0 和处理器 1。这是否意味着 Linux 正在报告CPU 的两个核心,或者,因为它是一个 VM,我现在碰巧拥有这两个核心(即使它们在物理上不同的 CPU 上) )?

其次,如何从 Windows 中的命令行获取类似的信息转储?

第三,有没有办法使用任一平台来确定物理CPU 的数量与CPU 内核的数量?

小智 8

关于第三个问题:

在 cpuinfo 中,有一个字段“物理 ID”,它是每个物理 CPU 唯一的。同一 CPU 的内核被报告为具有相同物理 ID 的不同处理器,而物理上分离的处理器将具有不同的物理 ID。

请注意,如果您在 VM 上,您无法了解有关实际硬件(CPU 等)的任何信息,您只知道 VM 告诉您的内容。因此,例如,如果您的物理机有 1 个四核 CPU,并且您的 VM 配置为报告 2 个单核 CPU,您将在 cpuinfo 中看到 2 个单核 CPU(即 2 个具有不同物理 id 的处理器)。

  • 谢谢,AmirW - 我正在使用的返回给我的确​​切命令是:`cat /proc/cpuinfo | grep 物理 | grep id | 排序 -u | wc -l` (2认同)

Ian*_* C. 7

回答您的第一个问题:http : //www.richweb.com/cpu_info 详细描述了所有 cpuinfo 输出,并在文章之后进行了一些有趣的讨论。

在您的情况下,它报告您的 VM 已配置为向操作系统显示自己为两个物理核心的 VM。VM 下的裸机可能是 1 核或 100 核,但就 VM 中的操作系统而言,您拥有一台可以使用两个物理处理器的机器。它不知道它分配给这些处理器的线程实际上是如何在 VM 下的物理硬件上运行的。

要从 Windows CMD shell 获取一些类似的信息,您可以尝试systeminfo从 CMD shell 执行命令。它显示的内容比/proc/cpuinfoLinux 中的要多得多,但也没有关于实际处理器本身的详细信息。

我不知道你第三个问题的答案,抱歉。