What are the “Threads” of a CPU and why do they exist?

622 views

What are the “Threads” of a CPU and why do they exist?

In: 1

5 Answers

Anonymous 0 Comments

A CPU executes the instructions that comprise your software. A core is the section of the CPU that contains the circuitry that performs these mathematical and logical operations (add, multiple, compare etc). CPUs do other things that aren’t part of the core, for example all the memory controller circuitry that allows it to interface with system RAM, or the I/O controller that allows the CPU to talk to other hardware like storage drives or graphics cards.

CPUs don’t have threads, applications do. CPUs execute them. A thread is a discrete unit of work that can be performed in parallel with other threads. Every application has at least one thread. A very basic application might have two threads, one for the program logic, one for the GUI. This allows the GUI to be responsive even while the application logic is busy doing it’s thing, crunching numbers or whatever. Some applications might have dozens of threads, if they are performing the kinds of tasks that can be split up that way.

Operating Systems do this thing with threads called scheduling. Basically, a CPU can only do so many operations at one time. The OS is responsible for giving each active thread some execution time with the CPU (in the order of milliseconds) before switching to the next thread. This switching happens so fast that even if the CPU isn’t physically capable of running all the threads at once, it gives the appearance of doing of doing so – multi tasking.

A CPU with one core can more or less only do one operation at a time*. A CPU with multiple cores, or a system with multiple CPUs, can potentially do multiple operations in parallel. So the more cores a system has available, the more threads it can execute simultaneously. But applications need to be designed with multi-threading in mind to make use of that parallelisation.

*For example, Hyper-threading is a feature of Intel CPUs that allows a single core to execute multiple operations at once, as long as those operations use different parts of the CPU core.

You are viewing 1 out of 5 answers, click here to view all answers.