Hi, in this post I will be covering the following:
- What are Processors?
- Why are they essential part of a computer system?
- How do they interface with the High Level code we write?
Processor is an electronic circuit, it is mostly made up of different types materials namely various types of plastic, aluminium , copper, silicon.
By the way did you know silicon is the most important material used in CPU for semi-conducting performance . Semi-conductors are conductors that are neither good conductors nor good insulators. It’s because of semiconductors we can miniaturize the electronic components e.g. Transistors, as the size is reduced they require less energy, and they are faster(in terms of passing information).
So processors take instructions and performs the required operations on them and gives an output. Inside the CPU there are a lot of wires that carry around information. In every CPU there is a wire that turns ON/OFF at a steady rate that is the “clock”, this clock help keeping everything in sync.
CPU are measured in Giga(Billion) hertz(times per second), so the clock turns on serveral billion times per second, this is the Reason why CPU is able to do complicated tasks quickly. Behind the Processor there are inputs, these inputs go inside the motherboard. Motherboard allows all the component to connect to each other. Each CPU has its own instruction set, something like LOAD to load data from RAM to processor or ADD to add two numbers. Using these instructions we can program the processor.
Inside the CPU there is a control unit, its the Admiral of the ship. It receives command from RAM, it then breaks command/instruction to forward to various components.
One of the major component is ALU (Arithmetic Logic Unit)- performs arithmetic operations like add, subtract, also comparison. The output is saved to a register temporarily. There is a system bus that connects all the components and carries information, also there are multiple registers that holds data and helps in processing. We need to understand one thing unlike the numerals that we have 0-9, computers has only 0/1. It understands combinations of 0’s and 1’s. Coming back to the question
How does the processor understand any of the code that we write in c++ or python?
Be it any programming language the high level code is compiled to machine code for the system to understand.
Python code is converted to intermediate code which has to be executed by a virtual machine(Python Virtual Machine), So every time a python script is executed a byte code is create i.e.. .pyc file. Byte code can be executed by virtual machine or can be further compiled to machine code that is understood by the processor. Byte code is similar to assembly language, it is somewhat readable unlike machine language.
Hope this was informative and i was able to clear some of the fog between the hardware/software interfacing.
Stay tuned Happy Coding!