Good afternoon. Today I would like to look at what threads are in a processor. The very ones whose functions and capabilities most people have no idea about, but love to show off to others.
If you compare processors of different generations, you will notice one interesting trend: multithreading is a useful thing and greatly increases the overall system performance.
Let's start with the fact that every modern processor is built on physical cores with a certain frequency. Let's say 1 core has a clock frequency of 3 GHz, i.e. can perform 3 billion computational operations per second (cycle). But modern operating systems (Windows, Linux, MacOS) run more than 3 billion processes, i.e. the user begins to encounter such a concept as an interruption: the CPU does not physically have time to process everything at once and begins to switch to the highest priority tasks.
The logic here is elementary: take a closer look at multi-core and multi-threaded solutions. Overclocking does not provide a linear increase in performance, otherwise giants such as Intel and AMD would release processors at 5-6 GHz or more.
There is a benefit from increasing the frequency, but it is offset by increased power consumption and reduced CPU life.
Single-core vs. multi-core processor
Firstly, we need to clarify the difference between single core processor and multi core processor? Simply put, a single-core processor will only be able to process one program at a time. However, when you are running multiple programs at the same time, then a single core processor will split all the programs into small parts and execute them simultaneously with time slicing, as you can see in the image below.
Process Execution: Single Core Processor
CPU performance will depend on the number of cores on the machine and the speed at which individual cores can execute instructions. So, if your website is loading slowly and you have a single-core processor, it may be worth purchasing a dedicated server with a multi-core processor or upgrading your hosting plan. Nowadays, this type of processors is rarely used because we need high computing power to solve our problems in the shortest possible time.
In contrast to single-core processing, it is a way in which computing tasks are divided into parts and a multi-core processor (multiple CPU cores) performs each sub-task simultaneously, as you can see in the image below:
Process execution: multi-core processor
This is also known as parallel execution because all the subtasks are executed in parallel and this is how many tasks can be processed at the same time. All modern processors used for commercial purposes must have multi-core processors to complete tasks in a shorter time.
Types of multithreading
As we said at the beginning, we all have the concept that multithreading is simply parallelizing processes (that is, doing multiple tasks at the same time), but in reality it is a little more complex and there are different types. multi-threaded processing.
Multiple "coarse grain" threads
The simplest type of multithreading occurs when a thread executes until it is blocked by an event, which typically creates a long-latency block. Such a failure can be caused by cache starvation, which must access off-chip memory, which can take hundreds of processor cycles to return data. Instead of waiting for the failure to resolve, the processor will switch execution to another thread that was already ready to run, and only when the data from the previous thread is received will it be returned to the list of threads ready to run.
This is conceptually similar to cooperative multitasking used in real-time operating systems, in which tasks voluntarily give up CPU execution time when they need to wait for some event. This type of multithreading is known as "block-based" or "coarse-grained".
Interleaved multithreading
The goal of this type of multithreading is to remove all data dependency locks from the execution pipeline. Because one thread is relatively independent of the others, there is less chance that a pipeline stage instruction will require the output of a previous instruction in the same pipe; This is conceptually similar to preemptive multitasking used in the operating system, and an analogy would be that the time slot given to each active thread is one CPU cycle.
Of course, this type of multithreading has the main disadvantage that each stage of the pipeline must keep track of the thread ID of the instruction it is processing, which reduces its performance. Additionally, since more threads are running concurrently in a pipeline, shared resources such as cache must be larger to avoid errors.
Parallel multithreading
The most advanced type of multithreading applies to processors known as superscalars. While a typical superscalar CPU issues multiple instructions from a single thread in each CPU cycle, with simultaneous multi-threading (SMT), a superscalar processor can issue instructions from multiple threads in each cycle. Recognizing that any thread has a limited amount of parallelism at the instruction level, this multithreading attempts to exploit the parallelism available across multiple threads to reduce the waste associated with unused space.
To differentiate between other types of SMT multithreading, the term "temporary multithreading" is often used to indicate when single threaded instructions can be executed concurrently. Implementations of this type include DEC, EV8, Intel HyperThreading Technology, IBM Power5, Sun Mycrosystems UltraSPARC T2, Cray XMT, and AMD's Bulldozer and Zen microarchitectures.
Thread vs Multithreading
A thread is a single sequential flow of control in a program that allows multiple actions to be performed within a single process. However, single-threaded processes rely on executing programs (or instructions) in a single sequence. Simply put, one thread is like one command that is executed at a time.
Read Reliable and Fast Copying with These Top Flash Drive Copiers
Most processor manufacturers use a technique called simultaneous multithreading (SMT) to ensure that a single processor can run multiple threads. Multithreading is similar to multitasking in which multiple threads are running simultaneously, and the multithreading capability manages multiple requests from the same user without opening multiple copies of programs running on the computer.
Hyper-threading technology
You've probably heard or guessed from the above that the more cores and gigahertz a processor has, the faster it processes the tasks you give it. This is true. But it’s not just the cores that affect performance when it comes to Intel brand products.
The company invented a technology called “Hyper-threading” (full - hyper-threading technology, HT or HTT), which is translated into Russian as hyper-precision. It is designed for processors based on the NetBurst microarchitecture.
HT is missing from Core 2 devices, including Duo and Quad. A similar technology with the same name is implemented in Core i3, i7 and several i5 products, as well as in some Itanium and Atom series models.
User threads vs kernel threads
User-level threads are user-side threads that are treated as a single thread process since the kernel is not aware of these thread types. These threads are much faster than kernel threads because they do not require kernel synchronization.
Kernel level threads are managed directly by the operating system and there is no thread management code in the application area. Any application can be scheduled to be multi-threaded and the kernel does its scheduling on a thread-by-thread basis. Compared to user-level threads, these threads are slower to create and manage.
Introduction
Performance has always been and remains one of the main characteristics of processors. It is constantly growing as the microelectronics industry masters new technological frontiers. In addition, without relying only on technological advances, processor developers are introducing various architectural and structural improvements, among which an important place is occupied by parallelism of calculations in all its manifestations: superscalarity, multithreading, multicore (multicore) and multiprocessing ( multiprocessing). In universal high-performance processors, all these approaches are combined as much as possible. However, levels of parallelism are interdependent, and in practice, due to their mutual influence, reasonable trade-offs must be made. The criteria for finding such compromises largely depend on the purpose and application of the processor. One such area that places specific demands on parallelism is network infrastructure, in which integrated network processors (INPs) have long been established and continue to be successfully used.
A qualitative analysis of the relationship between such widely used forms of parallelism of calculations in processors as multi-threading and multi-core allows us to identify the specific features of ISP from the point of view of these forms and evaluate their preferred directions for the development of parallelism of calculations.
Kernel vs threads
The question of whether threads or cores are more efficient is determined by measuring processor performance. You can test both methods yourself by running the same program (one that uses both threads and cores) on each type of CPU you have on your computer. Of course, programs using both methods must share CPU resources. If you have a desktop CPU and a laptop, you may find that the laptop CPU will perform better than the desktop CPU due to the higher number of cores. However, when testing a custom application on a dual-core CPU, you will notice a difference in performance between the two machines.
Options | Basic | Streams |
Definition | A CPU core is a physical hardware component. | A thread is a virtual component that is used to manage tasks. |
Process | The CPU accesses the second thread only if the information sent by the first thread is unreliable. | Multiple options for CPU interaction with multiple threads. |
Deployment | This can be achieved using the interleaving operation. | Performed by using multiple CPU processors |
Benefit | The CPU increases the amount of work done at a time. | Threads minimize deployment costs and increase GUI responsiveness. |
Use | It uses content switching. | Threads use multiple processors to manage different processes. |
Processing blocks | Requires one processor to operate properly. | Multiple processors are required to complete any task. |
Restrictions | Consume more energy as load increases | In the case of multiple processes running simultaneously, we can experience coordination between the OS, kernel and threads. |
Example | It can run multiple applications at the same time. | Launching search robots in a cluster. |
Instead of results
Practice shows that a modern universal PC should have at least 4 cores/8 threads, which will be enough for most data processing tasks. Although the options from the 6/12 series look more promising for the reason that they do not cost much more, and they provide more benefits.
As a “golden” mean, we can offer a fresh version of the model, built on the updated Zen2 architecture. It copes well with games, programs, parallelization and data processing, while racing perfectly (in a word, it has become popular (appeared in July 2019)).
We hope that you have gained useful information that will be useful when selecting a processor for a future system. Stay tuned for more articles on CPU anatomy.
Sincerely, Andrey Andreev
Final words
If you're planning to buy a dedicated machine soon, you might want to think about the trade-off between threads and cores or threads. Of course, you would want something more efficient given the amount of data and website traffic you plan to host on a dedicated server.
You may find that an application using a large number of cores can handle multiple tasks simultaneously without any stuttering or lag. But let's assume that the system you are using is for very simple applications or single threaded applications. In this case, it is advisable that you choose a simpler, lower-end hardware component to achieve better results.
If you find an error, please select a piece of text and press Ctrl+Enter.