The main element of any computer, laptop, smartphone and other electronic devices is the processor. This is the brain that makes digital cameras take pictures, players play music, and animators create new Avatars and Game of Thrones. How does this brain work? And how does he cope with all these tasks? In today's article, we will try to deal with these issues.
We will simplify the explanation as much as possible to save you from unnecessary details and get the essence of technology across. And we're not even going to try to explain what exactly happens in the processor when you click on a virtual button in a computer game. If you think about it, today's missile control systems, smartphones, and millions of different programs and devices exist today precisely because programmers don't have to think about the mechanics of computing processes. It's enough that everything works as it should, and it doesn't matter why or how.
From programs to microelectronics
This was made possible by so-called abstraction. Programmers work with virtual objects — this is the highest level of abstraction that lies at the maximum distance from the machine world and closest to the human world. Just below is the operating system level, where human-readable objects are converted into computer processes. You move the mouse — the operating system uses its own mechanisms that are responsible for tracking the cursor and controlling clicks.
If you go even lower, you'll be dealing with hardware — RAM, video card, the same processor. These are computer gears whose rotation allocates resources that in turn power the operating system, which in turn powers applications. This is where virtual processes become technical. If you drop acid on the motherboard, it will damage some specific chips, and the computer will start to fail the function for which the affected elements are responsible. When you come to a computer technician and complain that a program is freezing, he can imagine what material reasons for this problem may be — tracing its roots by levels of abstraction.
The internal structure of the processor
Each processor has two main units: a control unit (control unit, control unit) and a logic unit (arithmetic logic unit, ALU). Now we are not going to dive into the details of their work. The main thing to understand is that when executing computer programs, commands enter the control unit, which deals with the instructions, accesses various computer elements for the necessary data and transfers them to the logic block for processing.
The logic block can perform operations with numbers. He returns the result of his work to the control unit, which manages them further, in accordance with the conditions of the program he is executing. This division of duties allows the processor to effectively manage time: one unit manages processes, works with memory and other functional elements of the computer, and the second solves mathematical problems.
In principle, this scheme is used in any team work. There is always a manager who deals with organizational issues, communicates with the outside world, obtaining the necessary resources and data, and there are specialists who work with these resources and data to achieve their goals.
CPU duty cycle
All work operations within the processor are organized in a repetitive cycle: get instructions from memory, read and understand the command, execute it. This endless cycle is repeated over and over again while your computer is on. A special meter that is physically built into the chip is responsible for its control — this element, like a conductor, counts the clock, allowing the processor to accurately perform the necessary work.
This is where the concept of clock frequency comes from, which means how many times this conductor waves his wand in one second. The first wave — the processor receives instructions. The second wave is reading and understanding the team. The third wave performs it. If your computer or smartphone has a 2 gigahertz processor (a ridiculous figure in modern times), it swings two billion times every second. This fantastic speed of operations allows modern computers to show ultra-clear video with clear sound, draw 3D spaces in games, and perform many other operations that we buy computers for.
Despite all the breadth of possibilities, the set of instructions that the processor works with is quite small. He can read or write data to a specified memory location, perform some operations with it, remember the result, compare it with a number and take one action or another, whichever is greater. All the magic happens because these operations can be performed endlessly and very quickly, fulfilling the conditions of algorithms that programmers write.
Your computer's brain works on such, generally simple principles, proving ancient wisdom in practice: patience and work will ruin everything.