What the CPU is responsible for

За что отвечает CPU
How to

CPU - What is the most important element of a PC

The computer in our lives is both a sophisticated and familiar companion. Despite its widespread use, the working principle of this companion is still a mystery to many. A computer consists of a motherboard, power supply, hard drive, RAM, graphics card and a processor. Sometimes there is also a disk drive, but this element may as well be considered a vintage appendage, because disks are gradually disappearing from use.

Today we are going to pay special attention to the processor. For the processor, or CPU - Central Processing Unit, is the most important component, responsible for the computing process in the whole system. The CPU looks something like this:

But this is what it looks like already in the motherboard socket. This is called a socket. All motherboards have a socket. The only job of the socket is to be a slot for the processor. The aluminum CPU cover in the screenshot above is needed to protect and store the tiny silicon die. If you remove this aluminum cover, you will see roughly the following:

Two triangles soiled in an incomprehensible substance are the computer processor. The incomprehensible substance is the glue that holds the processor cover to the silicon stone. That tiny triangle is the pad for a trillion transistors. And transistors are tiny switches the size of a molecule. Transistors have only one function - they answer "Yes" or "No" to the computer by communicating with it in binary code.

The binary code is the ones and zeros you might have seen in the movie "The Matrix" or any other work on IT, hacking and other high-tech gadgets. The transistor itself doesn't solve anything. Their power is in quantity and size. Under a microscope, a transistor works like this:

Since there are trillions of transistors, each millimeter on the processor is responsible for only one function. Some groups of transistors are responsible for display output, others for logic, and still others for browsing.

Nothing is clear, but very interesting.
Nothing is clear, but very interesting.

In video games the processor plays the role of shadow conductor. It monitors the movement of objects on the screen, the physics and the logic. Have you ever noticed when something explodes on the screen during a game, splinters are flying in all directions, the place of the explosion is enveloped in flames, and the game slows down at the moment of explosion? This happens because the processor has a hard time telling each of the shards to move correctly. Weather effects such as rain, fog, thunderstorms, wind, water, vegetation are all handled by the processor. In quality open-world games, developers put colossal effort to ensure that the grass is crumpled under the feet of characters and the heads of dandelions plucked from the seeds and carried in the wind. Such little things will not consciously be noticed by 99.99% of players. But it's little things like that that make worlds convincing. The processor, on the other hand, is forced not only to notice such things, but also to obey the algorithm of their execution.

In 3D drawing and animation programs, the processor deals with the same tasks, but inside out: while in games the processor executes a knowingly written algorithm, in programs it memorizes them. Comparable to the homework assignment for a schoolchild - learn a poem. Learning a poem by heart and expressively telling it to the board are two different mental tasks, but over the same process.

In addition to games, the processor also does the rest of the calculations. The computer doesn't understand human speech, can't catch half a word, and can't think creatively, only by strict instructions. The processor also has such instructions. Dozens, if not hundreds, of instructions have been written over the years of PC existence. When the processor receives a task, it peeks at that instruction and acts strictly on it.

For example: the arrow shows a list of instructions that the Intel Core i7 9700K processor works with.
For example: the arrow shows a list of instructions that the Intel Core i7 9700K processor works with.

Instructions are needed for literally everything: for operating systems, for working with applications. Different processors have different instructions. That's why smartphone applications may not work on a computer - there is no right instruction.

But an instruction is the first step from the computer to the processor. An instruction is a "How" command, and now the computer needs to tell the processor "What". The PC operating system cannot control the processor directly, so it uses execution threads. These threads have a schedule of actions and serve as a kind of interpreter. Processes are the main task from the employer to the employee, and threads are the list of actions to execute processes.

To do this, you have to do this, this, and this. A very simplified explanation.
To do this, you have to do this, this, and this. A very simplified explanation.

Let's say a boss at work asks a subordinate to print out next month's work plan and hang it up in the office. The employee knows that to do this, he or she needs to visit the accounting department for paper, then go into the office with the photocopier, download the file to the computer and click "Print," pick up the copies, and hang them up on the board. In the example, "Print the work plan" is a process, and "visit the accounting department...", "go into the office with the photocopier," etc. - these are flows.

But this is where another processor trick comes into play - branch prediction. In layman's terms, branch prediction is the premature execution of a task before the task itself is submitted. In this way, the processor saves precious nanoseconds. A neural network does this complicated job. The neural network is constantly being improved in order to get a clear hit on the preemptive execution of the task. Incorrect execution, or, even worse, execution of the wrong task is fraught with the risk that the processor will have to build the prediction all over again.

But in simple words, branch prediction can be compared to a situation where an employee has already printed out the work plan for the next month on Monday. On Wednesday, the boss has given the order, "To have the work plan on the board by Friday." The employee pretends to take on the task, while he creates the appearance of working, playing solitaire on the work computer. But if the employee mistakenly typed that Monday not the work plan for next month, but "buy: eggs, carrots, butter, beer and chips for the European Championship," and then hung it on the board in the office, the boss will not understand such humor and will make you do it all over again.

And last but not least, multithreaded processor or SMT. Again, office work is the best example. In the aforementioned scene with the printing out of next month's plan, it wasn't just the boss and the employee who were actually present. In fact, the boss had many employees. He gave each one a small task, which is how corporations work. Our employee printed out the next month's plan, another one called the investors, and a third one is in charge of document turnover. But none of them deals with the tasks of their colleagues until the boss says so. It's the same in a processor: processes keep track of how threads do their work in the processor's pipeline. To do this, processors with SMT have a hardware module that keeps track of whether another thread can be added to the current thread. Thus threads work simultaneously on the same task. The success rate of such "workers" in the processor is measured in hertz.

The red arrow indicates a frequency of 1Hz, and the green arrow indicates a clock frequency of five thousand times greater.
The red arrow indicates a frequency of 1Hz, and the green arrow indicates a clock frequency of five thousand times greater.

Even modern processors can't handle all tasks at the same time. The high clock speed allows you to switch between tasks so quickly that you can't even notice the mess.

Plus d'articles