What Is a Computer Processor Thread


The Central Processing Unit (CPU) is usually referred to as the “brain” of your computer. It sits on the motherboard - the main circuit board - with the other physical components of your computer such as the Graphics Card and Random Access Memory (RA

Author: Trey Williams
Category: Hardware
Author: Trey Williams
Category: Hardware



The brief answer to this question is that, in computer processing, a thread is a short sequence of programmed instructions or code.

But that’s not very helpful all by itself, right? 

So, in order to properly understand what a computer processor thread is, and what it’s for, you must first understand the basics of how your PC processes information.

The Central Processing Unit

What Is a Computer Processor Thread

The Central Processing Unit (CPU) is usually referred to as the “brain” of your computer. It sits on the motherboard - the main circuit board - with the other physical components of your computer such as the Graphics Card and Random Access Memory (RAM).

It is responsible for almost everything your computer does and how it does it. When you ask your computer to do something, like running a program or downloading a file, it’s the CPU that makes this happen.

The actual processing part of the CPU is called the core. In the early days of computers, CPUs were all single-core, meaning they had only one processing unit, and so the words “core” and “processor” and “CPU” were used interchangeably.

All this changed with the introduction of Intel’s Pentium Processor Extreme Edition 840 in 2004 - the first dual-core processor available on the market. Since then, multi-core CPUs have become the norm and the majority of mainstream, off-the-shelf PCs now come with between 4 and 8 cores as standard.

An important point to note is that It’s physically possible, but rare, for a PC to be fitted with more than one CPU. It’s far more efficient for the single CPU to house multiple cores.

Now we know what the CPU is, we can take a look at what it does.

Programs, Processes, and Threads 

When you ask your computer to do something by inputting a command, the CPU follows a specific 3-step cycle to make this happen.

First, it has to access all the relevant information from where it is stored in the RAM. Then the CPU decodes those instructions before passing them on to the relevant units, or chips, that are responsible for carrying out the necessary function.

This initial mass of information that it retrieves from the RAM is the program - a collection of all the instructions that need to be followed in order to complete your command.

Each specific step or item in this list of instructions is a process. A process is also made up of a sequence (or sequences) of programmed instructions called threads.

Threads are smaller chunks of code, or instructions, which can be tackled individually and it is the act of working each of these individual “jobs” that execute the process. Hence, their full title is “threads of execution.”

Single-threading

If a process only has a single-thread, each section is worked in sequence until the thread is completed. Only then can the next one be started.

The downside of this is obvious. If the thread being executed goes into a “waiting state” or gets stuck for any reason, the processor cannot move on until the thread is completed. As a result, the whole program freezes up and becomes unresponsive. 

The reason for this (and this is important!) is that the CPU can only work one thread at a time.

Multithreading

The solution to this problem was to write programs which included processes made up of multiple threads.

Therefore, while thread A is in “waiting state”, the processor can switch its attention to thread B. When thread A is ready again, it jumps back. And so on. This is known as multithreading.

What is important to note is that the processor is still only working one job on one thread at any given moment in time. It’s working the threads within the process concurrently, but it’s not doing two things at once.

In multi-threading, the processor is not idle at any point and is, therefore, able to work much more efficiently. Multi-threading also helps to avoid crashes and non-responsiveness because, if one thread is stuck, the program is still able to respond by virtue of the other thread.

Multi-tasking

For simplicity, the descriptions above refer only to a CPU with a single core that is executing only one process within one program. 

However, all modern-day Operating Systems (OS) - even those with a single core - have the capacity to run more than one program and execute more than one process at a time. To do this, the OS behaves in a similar way to how the CPU handles multithreading; switching between processes and programs, sharing resources and allocating tasks as required. 

Again, by working jobs efficiently and never sitting idle, your OS creates the impression that its multi-tasking. In reality, a single-core processor can still only ever work one thread at any given moment in time.

Multi-tasking in the true sense of the word, then, has only been made possible by the introduction of multi-core processors. The one core, one thread rule still stands, but a quad-core processor, for example, can work four threads because it has four cores.

Simultaneous Multithreading (SMT)

With the growing demand for faster processing speeds and multitasking capabilities in recent years, technological advances have had no choice but to keep up. 

While it makes sense to increase the number of physical cores, this is still not as efficient as it could be. Increasing the number of cores increases performance, for sure, but there is still lost time in the transfer of data between individual processors. 

Wouldn’t it make more sense if each core could also do more than one thing at a time?

And so, as a logical evolution to multithreading, AMD developed what they refer to as Simultaneous Multithreading (SMT). 

SMT - or hyperthreading (Intel’s name for the same thing) - is the way in which a  single physical core works two threads simultaneously.

How is this possible if the core can only process one thing at a time?

To be honest, it’s just another illusion. 

As we’ve discussed, one physical core can still only work one thread at any given time. AMD and Intel have got around this perceived problem by developing hardware that convinces the OS that each physical core is two individual processing units, not just one.

The physical core shares resources with its virtual counterpart, which is then able to work threads in exactly the same way. Both processing units exist as far as the PC is concerned and, as such, it is unaware that anything is amiss.

And so, hyperthreading has the potential to vastly improve performance. Your dual-core will look to the OS like a quad-core, quad-core will look like an octa-core, and so on. Where you could realistically do four things at once, hyperthreading allows doubling of this.

It’s worth noting that hyperthreading is not a viable substitute for extra cores. A single-core processor utilizing this trick shouldn’t be any match for an actual dual-core processor not using hyperthreading.

Summary

Your CPU is responsible for making things happen when you enter a command or request into your PC. 

It works out how to do what you’ve requested by decoding the instructions in the program you’re running. Each step of decoding these instructions represents a single process and processes are made up of one or more threads. A thread is the smallest sequence of instructions that can be handled individually by your processor. 

Your processor can only work one thread at any given time but, as a result of efficiently switching between jobs on different threads, it speeds up processing time and gives the impression of multi-tasking.