应用程序运行于操作系统之上。现在操作系统,无论是Linux
、Unix
或Windows
,分时复用是基本的CPU调度方式。本文仅就Linux
操作系统,结合Achelous平台,探讨如何高效使用CPU资源。
资源cpus
在物理上对应什么?
Achelous平台上用户申请的CPU资源都是逻辑CPU核
,并不一定和任何物理CPU、核心或者超线程对应。如果没有打开核的超线程选项,物理CPU的每个核在操作系统中体现为一个逻辑CPU核
。如果打开了超线程技术,每个核会有两个物理线程,每个线程在操作系统中就是一个逻辑CPU核
。
例如在Linux
上运行命令cat /proc/cpuinfo
可以看到如下的信息:
[root@Cc1Apc ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
stepping : 4
microcode : 0x2000022
cpu MHz : 1022.656
cache size : 19712 KB
physical id : 0
siblings : 28
core id : 0
cpu cores : 14
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
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 nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnow