Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

I have a dual core core i5 with hyperthreading. Since hyperthreading allows for unused cpu time to be used by other processes, why would this make it seem like 4 logical processors (2 per actual core). How is this different than out of order execution?

Lets say core0/core1 are one core and core2/core3 are another. If core0 and core2 are at 100% is my cpu at 100% load or only 50%? If all of them are at 100%, what does that entail? Also, how come processes tend to execute on core0 and core2 rather than core1 and core3?

enter image description here

share|improve this question

marked as duplicate by Breakthrough, gronostaj, AthomSfere, soandos, Darth Android Jul 9 '13 at 14:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Related: How does Windows processor affinity work with hyperthreaded CPUs? (yes the question is Windows-specific, but my answer covers a lot of generic information related to Hyperthreading). –  Breakthrough Jun 26 '13 at 20:09
add comment

2 Answers

HT is like out-of-order execution, except that it can schedule a completely different thread instead of just reordering instructions. Sometimes the CPU sits idle because it's already reordered all of the instructions that it can, and it's still waiting on data or something else. HT allows another thread to be ready to run while the first is waiting.

There are still only two physical cores in your system. If core0 and core2 are at 100%, then your processor is at 100%. If the logical cores (core0, core1, core2, and core3) are all at 100%, then your CPU is actually running at about 115% of it's total without hyper-threading.

The reason you see the alternating core use is because core0 and core1 share the same physical core, and core2 and core3 share the same physical core. If the OS scheduled core0 and core1 instead of core0 and core2, then half the processor would sit idle most of the time.

share|improve this answer
    
How is hyperthreading "like out-of-order execution"? –  Breakthrough Jun 26 '13 at 19:54
    
@Breakthrough out-of-order execution is allowing various parts of the pipeline to be utilized by other instructions while other parts are busy (i.e., incrementing a register while the previous instruction is waiting for a memory fetch or write). Similarly, HT allows parts of the CPU that would otherwise be idle be utilized by another thread (as opposed to another instruction) in order to keep the CPU closer to 100% utilization. –  Darth Android Jun 26 '13 at 19:59
    
How can a cpu run at 115%? Would it be because during downtimes in a process, another proceess could run? –  agz Jun 26 '13 at 20:00
    
@agz see how Linux schedules processes, you can have a unit load greater than the number of cores in your system. –  Breakthrough Jun 26 '13 at 20:00
    
I thought having a system load avg being greater was just processes waiting to be executed –  agz Jun 26 '13 at 20:01
show 5 more comments

Since hyperthreading allows for unused cpu time to be used by other processes, why would this make it seem like 4 logical processors (2 per actual core). How is this different than out of order execution?

This isn't wholly correct. Hyper-threading simply adds an additional execution unit per core (in hardware), but shares the rest of the core, which is why in certain cases hyperthreading can actually reduce performance. Furthermore, hyperthreading does not explicitly "allow unused CPU time to be used by other processes". That is handled by your operating system's process scheduler.

Hyperthreading does, however, expose another "core" to the operating system, allowing it to schedule more programs to run simultaneously. Except in the cases where this would exhaust the shared hardware in a Hyperthreaded core (e.g. if two threads are running on separate execution units in a Hyperthreaded core which heavily use the cache, which is shared by both threads in a HT-core). For technical details about hyperthreading, see the Intel Core Processor Datasheet, Volume 1.

Lets say core0/core1 are one core and core2/core3 are another. If core0 and core2 are at 100% is my cpu at 100% load or only 50%? Also, how come processes tend to execute on core0 and core2 rather than core1 and core3?

It depends which parts of your processor are being stressed (performance gains by HT is very application-specific, again see above). Technically you might only be using 50% of the execution units in Core 0, but the rest of the hardware in the core might be loaded at 100% (e.g. if the program makes heavy use of cache).

For details, see the question How does Windows processor affinity work with hyperthreaded CPUs?.

share|improve this answer
add comment

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