Hyper Threading : Performance Booster for CPU

Niraj Bhoi
4 min readMay 25, 2021

Nowadays Hyper threading becomes more popular due to its ability to make processor faster. It improves the CPU performance up to 30% in many server applications. Hyper threading is the advanced form of multi threading. Before starting with the hyper technology we need to understand some basic information about threads ,processes and multi threading.

Thread

The thread is the single segment of the execution process. Threads are very small sequences of instructions,these instructions are also known as the Lightweight process. When we see the execution of the threads, they gives the illusion that they are executing in parallel . But after observing neatly we will get to know that the threads executing one after another. It has mainly three states.

1.Register :- Hold variables

2. Program Counter :- Keeps the track of instructions

3. Stack :- Save execution history

Types of thread

  1. User level threads

These are the user manged threads. The kernel does not have any information about these threads and treats them as a single threaded processes. It can be implemented on any operating systems because it doesn’t interrupt the kernel. If one of the thread causes the fault the entire process will be stop.

2. Kernel level threads

These threads are managed by the kernel itself. The kernel has its own thread table through which it manages the threads. In kernel space the kernel performs thread creation, scheduling and its management. If one of the thread causes the fault the kernel schedules another thread for the same process. But when it comes to the speed these threads are very slow .

Multi threading

Multi Threading is the ability of the CPU to supply threads to execute the processes. This is different from the multi processing. In multi threading the threads share the resources. In simple words multi threading means dividing work for a simultaneous process. It is of three types

  1. Many to many model :- It multiplexes the user threads to equal number of kernel threads
  2. Many to one model :- It maps many user level threads to one kernel level thread
  3. One to one model :- It is one to one relation of one user level thread to one kernel level thread

Now lets understand Hyper threading

The simple from of simultaneous multi threading technology is known as hyper threading. It is first introduced by the Intel. In 1973 first paper published which contains one great technology , which was written by Edward S. Davidson and Leonard. E. Shar. The technology in the paper is now known as Hyper Technology. The hyper threading technology is a transparent technology to OS.

A processor having hyper threading technology consists of two logical processors, where each logical processor has its individual architectural state.These logical processors can be halted and can be interrupted individually. While, The other logical processor shares the common physical core these logical processors can execute the specific thread.

The other normal dual processors uses two physical processors for execution, but in hyper threaded core the logical processors shares the execution resources. With this sharing feature the two logical processors can work with each other systematically. The resources includes caches, system bus interface and execution engine.

Hyper threading works by duplicating the section which stores the architectural state. But it doesn’t duplicates the main execution process. Because this logic the hyper threading processor looks similar as the traditional processor. The extra logical processor allows the OS to schedule two threads simultaneously.

Lets consider one example

Symmetric Multi processing System(SMP) is best to know how hyper threading works. The SMP consists of two hyper threaded physical processor , which means it has 4 logical processors. If the thread scheduler of the OS doesn’t know about the hyper threading then it treats all logical processor as same. Now we have to execute processes through only two threads the normal OS schedule the threads to any logical processors. This leads to poor performance of the OS,because the only two processors are free and the entire load goes on other two processors. This problem can be resolved by using hyper threading. Hyper threading allows the scheduler to treat the four logical processor differently and improves the performance.That’s why the hyper threading is very important.

Implementation of Hyper threading

The hyper threading technology is reliable and can easily implemented.We can pass thread through various methods . Mainly three methods are implemented which are

  1. Replicated Resource :- It maintain two fully independent resources on each logical processor . The well known example is instruction pointer (IP). This pointer helps the processor to keep the track of its place in instruction stream.It is done by fetching the next instruction.
  2. Partitioned Resource :- The resources are mostly found in the queue form. This resources decouple the major stages from one another. There are two types of partitioned resource . First type is statically partitioned, in which the queue is splitted in two parts. The first part for one logic processor and the other part designated for the other processor. Second type is Dynamically Partitioned , instead giving a specific queue entries to logic processors it allow processors to use any queue entries also it set the limit to each processor.

3. Shared Resource :- Its like an heart of hyper threading. As more as you share resources between logical processors, the more efficient hyper-threading can be done. It squeezes the maximum amount of computing power from the minimum amount of die space.

Thanks for reading…!

--

--