77

I am confused, because when I see my mac about window, I see

enter image description here

That I have 1 Processor and 4 cores. But when I run htop, I see 8 cores

enter image description here

What am I missing?

0

6 Answers 6

53

What am I missing?

Hyperthreading. You have 4 physical cores, but 8 logical ones.

For each processor core that is physically present, the operating system addresses two virtual (logical) cores and shares the workload between them when possible.

See also the Intel data on your processor, the i7 4870HQ:

# of Cores 4

Cores is a hardware term that describes the number of independent central processing units in a single computing component (die or chip).

# of Threads 8

A Thread, or thread of execution, is a software term for the basic ordered sequence of instructions that can be passed through or processed by a single CPU core.

139

From a terminal you can see the difference between the number of physical processors and logical processors using sysctl:

$ sysctl hw.physicalcpu hw.logicalcpu
hw.physicalcpu: 4
hw.logicalcpu: 8
5
  • 9
    Why was this downvoted ? This command works (at least on El Capitan). Oct 29, 2018 at 11:43
  • 1
    works in mojave too
    – divine
    May 15, 2020 at 0:56
  • 1
    Still works in Catalina as well. Upvoted. Nov 27, 2020 at 15:34
  • 3
    It's working on Big Sur...
    – AFK
    Feb 18, 2021 at 22:17
  • Worked for me on Monterey.
    – dstromberg
    May 17 at 19:27
4

What you see are so called hyperthreaded cores.

For each physical core there are two hyperthreaded (or logical) cores, you can read up more about hyperthreading here

0
4

your CPU is an i7, so it has Hyperthreading, which presents itself to system monitoring applications by doubling the number of cores, since each can process two threads semi-simultaneously.

0

It has 4 physical cores and 4 logical cores giving you the total of 8 cores.

This is called Hyper-threading

1
  • 11
    This is wrong. There are 4 physical cores, and each physical core has two logical cores. So there are 8 logical cores.
    – Yongwei Wu
    Aug 2, 2019 at 10:49
-1

While most of the answers here are providing the link to Wikipedia (which is correct!), I just want to list a paragraph from the same article which helped me understand how can the logical processor work.

Hyper-threading works by duplicating certain sections of the processor—those that store the architectural state—but not duplicating the main execution resources. This allows a hyper-threading processor to appear as the usual "physical" processor and an extra "logical" processor to the host operating system (HTT-unaware operating systems see two "physical" processors), allowing the operating system to schedule two threads or processes simultaneously and appropriately. When execution resources would not be used by the current task in a processor without hyper-threading, and especially when the processor is stalled, a hyper-threading equipped processor can use those execution resources to execute another scheduled task. (The processor may stall due to a cache miss, branch misprediction, or data dependency.)

Source: can you guess?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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