Why is my dual-core CPU recognized as a quad-core one?
My processor is an Intel Core i3-380m. As you can see, it's 2 cores and 4 threads.
Although, both Ubuntu 11.04 and Windows 7 seem to think it's a quad-core CPU:
Why is this? Is it because there are 2 threads per core, dividing the CPU in 4 processing units?
Solution 1:
As mentioned you have a dual-core system, with 2 threads per core.
This is marketed by Intel as hyperthreading and has been done in various ways over the years by various different manufacturers.
To explain it in its simplest form each CPU core consists of a "core" and various architecture around that core that keeps state and process information for each thread. A single threaded core has the architecture to keep 1 thread worth of state information held at a time, a hyperthreaded core keeps two distinct sets of state information, allowing two separate processes to run at once as long as they require different parts of the core (which is reasonably likely to happen as the core consists of multiple units of multiple different types of processing unit).
To simplify how the CPU is seen to the system each hyperthread is seen as a separate CPU, so a dual core, 2 thread per-core processor appears as a quad core processor.
It is also possible for the operating system to use Core-parking (a feature in newer Intel processors) allows the operating system to suspend one half of a hyperthreaded core so that when the extra processing ability of hyperthreading is not needed then the single thread performance is increased as the core is no longer sharing it's cache across 2 threads and can now fully devote the on-core cache to a single thread.
Solution 2:
The reason is hyperthreading, which your processor supports. Hyperthreading isnt the equivalent of an extra processor, but can really boost performance on multithreaded applications. For each processor core that is physically present, the operating system addresses two virtual processors, and shares the workload between them when possible.
Solution 3:
Things are a lot more complex than they were in the days of one cpu instruction per one clock cycle.
There's now a pipeline for each instruction that consists of a number of steps. I've heard as many as 41, though that was a while ago and I have no idea what current cpu pipelines look like. I do know that if the pipeline is long enough, you can start a new instruction down the pipeline before the last instruction has finished, sometimes in the same clock cycle, so that your single core is effectively doing two things at once.
There's a trick here, though. You can't just use this to speed up the rate at which your processor chews through instructions from a specific program. There's a correctness issue involved: the next instruction might depend on the as-yet-undetermined result of the prior instruction. To take advantage of the long pipeline safely, the chip will present two separate processor cores to the operating system scheduler, and alternate instructions sent to each core so that two instructions to the same "core" are never in the pipeline at the same time. This way it we can be sure that any instructions executed simultaneously will not interfere with each other. This is called hyperthreading.
It's worth noting here that while hyperthreading can significantly increase the amount of work you get out of your cpu, it's nowhere near as good as having that many physical cores. Depending on your work-load, it might means as little at 15% improvement or as much as 40% improvement. In some circumstances, you may even want to disable the feature so that the remaining cores have full exclusive access to the L1/L2 cache for that core (this is sometimes done with dedicated database servers).
When your chip advertises itself as having 2 cores with 4 threads, that means it's a dual core processor that supports hyperthreading.
Solution 4:
Take a look at this intel page- it has lots of animations showing how hyperthreading speeds up your tasks.
The Utilization of Processor Resources
is the best animation, look at it and them click the "advance" button.