How Computers Work – Part 5 – The CPU [Mega Series]
What Does the CPU Do?
Every microprocessor is built to perform math and process information, hence the name “processor.” It does this with simple transistors and registers which are equipped to perform certain functions, like fetching memory, subtracting, adding, etc. As the decades passed, these chips became smarter and more efficient, while today’s chips can follow billions of instructions in one second.
What a Transistor Does
A transistor is basically a little piece of semiconductor material that switches electrical current and/or amplifies a signal. It’s easier to think of each transistor as an on/off switch, because that’s what your computer is: A gargantuan collection of on/off switches, each with their own function in the grand flow of data governed by Computer Science.
Each of these transistors are structured in a way that serves a particular purpose, such as fetching a memory address or writing to it. The CPU determines what it should do with its transistors based on the machine code sent into it, creating tasks. That’s basically what makes everything work when you click a mouse on a button and out pops a result.
Let’s say you close a window. The CPU fetches the graphical data of the window and tells the graphics adapter to close it. It then fetches the memory address associated with the window (in RAM or your hard drive’s virtual memory) and deletes all the memory located there, and then it continues to check for further mouse movement. This is a simplified version of what happens, but it’s a general idea you can easily understand.
What a CPU Does, Cont’d
CPUs perform the most elegant functions of the computer:
- Memory manipulation, and
- Decisive tasking
It performs these functions with four simple components:
- Arithmetic Logic Unit (ALU)
- Address bus
- Instruction registers, and
The CPU has an arithmetic logic unit (ALU) which performs all the adding, subtracting, division, and multiplication on your computer. Its address bus makes it possible for the processor to directly work with any memory on your computer, deleting and adding information. The cache, and all its levels, keep track of all tasks and memory addresses that are most actively used at the moment. Your CPU’s instruction registers carry out all the tasks on the computer, queueing them as they accumulate, and processing each as the processor becomes free.
The processor’s clock determines how fast it works. This clock usually is governed by a crystal that oscillates at a fixed rate per second. The amount of oscillations per second is then multiplied by a number set by the motherboard’s BIOS and turned into the CPU’s clock. Every time the CPU’s clock “ticks,” the CPU carries out one instruction. Hence, a CPU with a clock of 3.33 GHz executes 3.33 billion instructions per second. Be careful not to mispronounce “clock” when telling your friends about this. I’ve had my share of embarrassing moments!
A CPU doesn’t just operate on its own. Let’s say you were reading this article, watching a video of some guy falling off his bike, annoying your co-workers via instant messenger, and calling your ex on Skype in a drunken fit of rage. Wouldn’t all of that be easier if you had four processors?
Not necessarily… You see, CPU manufacturers came up with a new concept that blows the multi-processor idea out the window, and decided to include cores inside the processor. Each core is almost like an individual CPU, with its own address bus, ALU, and instruction register. While still sharing the cache between each other, cores make multitasking much faster where it originally would have taken four times as much muscle to do four non-productive things on your computer at the same time (except, of course, reading this article). If you have heard of the terms “quad-core” or “dual-core” before, this is what the terms refer to. Cores aren’t the only things that processors have been beefed up with, though.
Instead of adding multiple cores like a wild fox, Intel decided it’s time to invent a proprietary system in which two parallel instructions can be executed on one single core.
The Foster Xeon from Intel was the first microprocessor to execute instructions in a hyper-threaded environment. This was intended to make a processor double its multitasking capacity and further increase productivity. If you have a quad-core processor with hyper-threading capabilities, that means that you have the equivalent of a whopping 8 processors on your computer. You may now proceed with patting yourself in the back for understanding what I just said.
64- and 32-bit
One of the most common questions today: Is 64-bit better than 32-bit?
Most programs out there as of the time of this publication don’t need a 64-bit processor. The “64-bit” and “32-bit” denominations represent a bit width, which in laymens’ terms represents the amount of information the CPU can store in one register at one given time. To first understand the concept of these two bit widths, you need to be able to picture a register.
If you notice, the register itself is built upon the registers of predecessor processors. A long time ago, we had 8-bit processors. The 16-bit processor included just two 8-bit registers, and so on. The diagram isn’t completely accurate, as far as proportionate size is concerned, but the only thing I wanted to demonstrate was the hierarchy of a register.
A 32-bit program can run on a 64-bit processor because it still has the EAX register. A 64-bit program, however, cannot run on a 32-bit processor, because there is no RAX (64-bit) register on these processors. Even so, you still have to install a 64-bit operating system on the computer to benefit from the 64-bit register. Otherwise, it will only recognize EAX, and not RAX. Are you lost? Read it again, about 4500 times. It’ll catch on.
If you didn’t understand the above, all you need to know is that a 64-bit processor is “better” only if you run 64-bit programs. 32-bit programs won’t run better on a 64-bit processor, but they will run anyhow.