Processor (CPU β Central Processing Unit)
π‘ In my earlier post, I introduced the idea of internal components and gave an overview of how they all fit together. If you missed it, you can read it here: π “Whatβs Inside Your PC“
π Note: This post is written for beginners. Donβt worry, no heavy tech jargon here π β weβll keep it simple and only cover the basics of processors and the CPU. Advanced architecture concepts are not included in this post
The CPU is often referred to as the brain of the computer. It executes instructions from software and ensures that all other parts of the system work together smoothly. Without the CPU, a computer cannot function. At a very high level, the CPU is responsible for carrying out instructions from both the operating system and applications.
- Every action you take on your PC β opening a file, browsing the web, running a game β ultimately passes through the CPU.
- It works in a cycle often described as fetch β decode β execute β store:
- Fetch β CPU fetches the instruction from memory.
- Decode β It interprets what the instruction means.
- Execute β The CPU performs the task (like an addition, comparison, or move operation).
- Store β The result is written back to memory if needed
How it connects to the motherboard:
CPUs are placed into sockets on the motherboard. Two common socket types are:
- PGA (Pin Grid Array): The CPU has many small pins on its underside that fit into matching holes in the socket.
- LGA (Land Grid Array): The socket has pins, and the CPU has flat contact points. Intel CPUs often use this type.
π In short: CPU decides and directs, while the socket (PGA or LGA) is how it βsitsβ and communicates with the motherboard.
CPU Characteristics β Architecture
When we talk about CPU architecture, we are describing how the processor is designed and how it handles data and instructions. A few important terms are:
32-bit vs 64-bit
The βbitβ refers to the width of the processorβs registers β tiny storage locations inside the CPU that hold instructions, memory addresses, or data while the CPU works. A 32-bit CPU has registers that are 32 bits wide (can hold numbers up to 2Β³Β²), while a 64-bit CPU has registers 64 bits wide (up to 2βΆβ΄). This affects the amount of memory (RAM) the CPU can utilize. For example:
- 32-bit CPUs can access up to about 4 GB of RAM.
- 64-bit CPUs can use much more memory, which is why most modern systems are 64-bit.
ARM
- ARM stands for Advanced RISC Machine.
- Itβs a type of CPU architecture that is very power efficient and is mostly used in smartphones, tablets, and some laptops.
- ARM CPUs focus on doing tasks quickly while consuming less power, which is why your phone battery can last hours.
RISC vs CISC
These are two different design philosophies:
- RISC (Reduced Instruction Set Computer): Uses a smaller set of simple instructions that can be executed very quickly. ARM is an example of RISC.
- CISC (Complex Instruction Set Computer): Uses a larger set of more complex instructions, often found in Intel and AMD desktop processors.
π In short:
- 32-bit vs 64-bit β Memory handling power.
- ARM (RISC) β Power-efficient, common in mobile devices.
- CISC (Intel/AMD x86) β Powerful, common in desktops/laptops.
CPU Characteristics β Speed
The speed of a CPU shows how quickly it can process instructions. It is usually measured in Hertz (Hz), which means βcycles per second.β
- Clock Speed
- A CPU works in cycles β like the ticks of a clock.
- The faster the clock, the more instructions the CPU can execute each second.
- Modern CPUs are measured in GHz (Gigahertz). For example:
- 3.0 GHz = 3 billion cycles per second.
- A higher clock speed usually means faster performance.
- Cores
- Early CPUs had only one core (one brain).
- Modern CPUs often have multiple cores (dual-core, quad-core, octa-core, etc.).
- Each core can work on its own task, allowing the CPU to perform multiple operations at the same time (multitasking).
π In short:
- Clock speed = how fast the CPU runs.
- Cores = how many things it can handle at once.
CPU Characteristics β Cache
The cache is a small, high-speed memory built right into the CPU.
- Its purpose is to store frequently used instructions and data so the CPU can access them quickly.
- This avoids delays from repeatedly fetching the same information from the slower main memory (RAM)
Types of Cache (usually mentioned in books):
- L1 Cache: The smallest (a few KBs per core)and fastest, located closest to the CPU cores.
- L2 Cache: Larger than L1(hundreds of KBs to a few MBs), a bit slower but still faster than RAM.
- L3 Cache: Even larger(several MBs, shared by all cores), shared across cores, but slower compared to L1/L2.
π Order: L1 β L2 β L3 β RAM (each step gets bigger but slower).
CPU Cache Analogy
Think of the CPU as a student working on homework:
- L1 Cache = Pocket π§₯
- The student keeps a tiny notepad in their pocket with the most important formulas.
- Itβs the fastest to grab, but space is very limited.
- L2 Cache = Desk πͺ
- The student keeps a bigger notebook on their desk.
- It takes a bit longer to reach than the pocket, but it holds more notes.
- L3 Cache = Bookshelf in the same room π
- The student has a bookshelf nearby with many reference books.
- Itβs larger but slower to reach compared to the pocket or desk.
- RAM = Library down the hall π
- If the student doesnβt find what they need in pocket, desk, or bookshelf, they have to walk to the library (RAM).
- Much slower compared to cache.
π In short: The closer to the CPU, the faster but smaller the storage.