Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I run cat /proc/cpuinfo I get the following output (only the relevant line included):

cpu cores: 1

However, lscpu gives me the following output:

CPU(s): 2

Which of the two is correct, and more importantly, why are they giving me different results?


The full output of cat /proc/cpuinfo is:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 15
model       : 3
model name  : Intel(R) Pentium(R) 4 CPU 2.80GHz
stepping    : 4
microcode   : 0xe
cpu MHz     : 2800.135
cache size  : 1024 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 5
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 constant_tsc pebs bts pni dtes64 monitor ds_cpl cid xtpr
bogomips    : 5600.27
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 32 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 15
model       : 3
model name  : Intel(R) Pentium(R) 4 CPU 2.80GHz
stepping    : 4
microcode   : 0xe
cpu MHz     : 2800.135
cache size  : 1024 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 1
initial apicid  : 1
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 5
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 constant_tsc pebs bts pni dtes64 monitor ds_cpl cid xtpr
bogomips    : 5600.27
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 32 bits virtual
power management:

The full output of lscpu is:

Architecture:          i686
CPU op-mode(s):        32-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    2
Core(s) per socket:    1
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            15
Model:                 3
Stepping:              4
CPU MHz:               2800.135
BogoMIPS:              5600.27
L1d cache:             16K
L2 cache:              1024K

(This can also be viewed at https://gist.github.com/IQAndreas/f3f9139b8968987d3716.)

share|improve this question
    
those commands tell us your CPU and the information can then be determined. Please update your question with the output of your commands or at least lscpu | grep Model –  bodhi.zazen Aug 31 at 20:08
    
@bodhi.zazen The full output for both commands has been added to the question. –  IQAndreas Aug 31 at 20:42
    
I have a guess at what happened; cpuinfo has two "sections", one for each core. I missed this when looking at the output in a smaller terminal window, however, it became very visible to me when the full output was pasted into a Gist. Can someone confirm that this is indeed how cpuinfo displays its output? –  IQAndreas Aug 31 at 23:28
    
Please re-read the output. Both show two single-core cpus, I do not see a contradiction. –  user322595 Sep 1 at 10:40
1  
The cpuinfo output shows information per execution threads. An Intel CPU with HyperThreading will show one output block per "thread". The cpuinfo output will contain one block per core on a multi-core CPU, or simply one block per populated socket. The output of cpuinfo gets really long when you have multiple Intel CPUs, each with multiple cores and HyperThreading enabled. –  dan_linder Sep 2 at 20:29

1 Answer 1

This is consistent with having a single processor containing a single core which contains two execution threads through hyperthreading. Thus you have two logical processors, but they share most of their resources (instruction decoding, arithmetic, etc.). This allows some parallelism — one thread can progress while the other one is blocked (e.g. waiting for a memory access) while keeping the hardware cost down (fewer components than two independent cores).

Look at the rest of the output from lscpu and the content of /proc/cpuinfo. See So what are logical cpu cores (as opposed to physical cpu cores)? for an example.

share|improve this answer
    
Really it's only the out-of-order execution core that is shared in a processor with hyperthreading. Each virtual CPU has instruction decoding. –  David Sep 1 at 7:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.