Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Threads vs Cores

Tags:

Say if I have a processor like this which says # cores = 4, # threads = 4 and without Hyper-threading support.

Does that mean I can run 4 simultaneous program/process (since a core is capable of running only one thread)? Or does that mean I can run 4 x 4 = 16 program/process simultaneously?

From my digging, if no Hyper-threading, there will be only 1 thread (process) per core. Correct me if I am wrong.

like image 624
teonghan Avatar asked Jul 09 '10 10:07

teonghan


People also ask

Is it better to have more cores or threads?

The advantage of having several cores is that each core can handle a different data thread simultaneously, allowing for a much quicker transfer of data at any given time. A high clock speed means faster processor.

Does 8 cores mean 8 threads?

The number of threads you have depends on the number of cores in your CPU. Each CPU core can have two threads. So a processor with two cores will have four threads. A processor with eight cores will have 16 threads.

What does it mean by 4 cores 8 threads?

This means that it only has 4 processing units (Cores) but has support in hardware to run 8 threads in parallel. This means that a maximum of four jobs run in on the Cores, if one of the jobs stall due to for example memory access another thread can very fast start executing on the free Core with very little penalty.

Is 4 cores better than 4 threads?

4C/4T is inherently superior to 2C/4T which is better than 2C/2T. More threads lets you process more independent things at the same time (eg, running two programs actively) whereas cores let you run intensive tasks (or multiple tasks) concurrently.


1 Answers

A thread differs from a process. A process can have many threads. A thread is a sequence of commands that have a certain order. A logical core can execute on sequence of commands. The operating system distributes all the threads to all the logical cores available, and if there are more threads than cores, threads are processed in a fast cue, and the core switches from one to another very fast.

It will look like all the threads run simultaneously, when actually the OS distributes CPU time among them.

Having multiple cores gives the advantage that less concurrent threads will be placed on one single core, less switching between threads = greater speed.

Hyper-threading creates 2 logical cores on 1 physical core, and makes switching between threads much faster.

like image 52
Alex Avatar answered Nov 15 '22 09:11

Alex