
Demystifying how a computer works.
February 14, 2008“After you press power, before you open up Word.”
This is a relatively short coverage of how a computer works intended to be understood by someone that knows what a computer is and how to use basic applications. The goal here is to explain to someone that uses a computer what all is going down inside that magical box on their desk.
(continued)
Preface: This is pretty long, so I only have one version of it here for now. The first one I wrote talked about MUXs and binary and was far too complex for my first intended audience. After a run past my editor, I ended up writing this one. The original is now in a state of disrepair and needs to be rewritten itself.
Anyway, Here we go.
At the most basic level a computer is a whole bunch of highly organized switches connected to each other in a very complex way. The most basic organization of these switches is into logical circuits. A good example of one of these is a light in your home that is simultaneously controlled by two switches. These switches are called inputs, and the light is the output. The light may be on only if both light switches are up (in the on position), if either or both is up, if only one of them is up, or any other arrangement as long as it is consistent.This simple device, two light switches controlling one light, or two inputs controlling one output is the basic building block that nearly every computer is built on. Making the outputs from one switch/light set feed into the inputs of a different switch/light set is the next step. Using our example imagine that the light in your home controlled by two switches now itself becomes one of two switches that controls a different light. This is what is essentially going on inside your computer, only there are millions of these tiny switches with their inputs and outputs interconnected in highly complex, yet logical networks.
These switch networks are everywhere inside your computer, but let’s try to think of them inside your main core processor. This is that big chip that has all those heat sinks and fans all around it if you opened up your computer. You might not be able to see the chip itself since it is encased in a protective cover and has all that cooling hardware on it, but you’ll recognize where it is. If you have ever seen a processor, any kind of chip, or even a monitor plug, you will see that it has pins on it. You may wonder how so few pins can be used to control everything, after all your monitor plug only has less than 30 pins on it. How can that possibly control every pixel on your monitor using only on or off? Each of those pins can have a charge on it or no charge on it, on or off, just like the switches and the light. There is a clock inside your computer too that ticks off very fast and the charges on those pins will be different on each tick. When you hear a processor speed is 1GHz (gigahertz) that means that every second, that clock ticks off about 1,000 times, and each time your main processor can have a different input and different outputs.
There is a lot going on inside your processor, and far more inputs that can be accessed than there are pins. Along with the clock ticks, there is a selection scheme going on where some of the input pins are used to select what the other pins are being used for.
A processor is set up to process simple commands called instructions. Generally these have three inputs and one output. One input is the instruction and the other two inputs are numbers. They are actually all just numbers, represented as a string of 1s and 0s (on and off). The first input is the number which indexes a specific network of logic switches on the processor. The other inputs might be two numbers you wish to add, a number and a memory location to store it in, two memory locations you wish to add, or even an index to another instruction or list of instructions. Converting these numbers into a more readable format is called assembly language.
Here is a short example of an ADD instruction on a 4 bit processor. Remember that whenever a computer handles a number it is represented using a string of 1s and 0s. To keep things simple numbers will be shown the way you are used to, and marked bold. On this processor the ADD instruction is the 5th instruction this processor can do, so it is indexed by 5. To tell the processor to add one and one we would send the following three inputs: 5 1 1. The first one tells the processor to add the other two numbers. The answer would be stored in a standard location on the processor, so then if you wanted to use that number again you might use a slightly different ADD instruction (with a different index) which does the same thing (adding), but uses the number in the first register and another number you provide. Programs are not written this way, but whatever language you are using is converted to a list of these instructions using another program called a compiler. When you run a program on your computer, you are basically running a list of instructions made up of these simple three input, one output commands to the processor.
Whew… ok that should give you a basic idea of what is going on. I have been focusing mostly on what is going on in the processor, but it’s the same sort of thing happening everywhere else in the computer. Instructions and numbers to use with them are moving all over the place: saved in memory, retrieved from memory, retrieved from a hard disk/DVD/flash drive, shown as a colored pixel on the monitor. There are smaller processors and bits of memory all over the place that are maybe not as powerful or as fast as the main processor. Yet they are functional enough to handle requests and help make decisions about the information that is sent to it and what to do with information coming from it.
When you turn your computer on, the first thing that happens is all the different components get power. The one plug in the back of your computer is converted and split into various voltages and currents and is distributed to all the individual components in your computer (i.e. processor, CD/DVD drives, fans, etc). The next thing that happens is a computer chip called the BIOS takes control and starts running a program stored in its memory. The program is saved in memory sort of like what is on a flash drive, nothing moves to access it and turning off the power does not erase it. The BIOS program talks to the main system board (called a motherboard) and finds out what is connected to it. The first thing it looks for is a monitor and a keyboard and then gives you the opportunity to enter its configuration options. After that it continues to look for and initialize all the other parts that are attached to it like hard drives, mice, sound cards, etc. If there is a problem with your system hardware you might see it now. Finally your BIOS tells your operating system (Windows, Mac OS, etc) to start and that program starts to run.
No matter how your computer is set up, they all operate with these same basic principles. Even your cell phone uses these simple switches interconnected in a very complex way to run a pre-programmed set of instructions.