What I find amazing about computers is how simple, and similar, they all are.
Yet, when we buy them wrapped in plastic shells and are told “Don’t touch that”, they quickly becomes kin to magical artifacts. How do they work? Why do they work? If it breaks, what do we do?
Computer stores seem to give us little permission on how to explore these questions.
The good news: understanding how a simple computer works will allow us to understand how all computers work.
Let’s begin by exploring what happens when we turn on a computer.
Computers need power. Electricity is one of the things that make every computer the same–electricity works a certain way.
Electricity can come from a wall socket, battery, solar or windmill…it doesn’t matter. A computer itself doesn’t know: it just knows it’s getting electricity from somewhere.
Most computers have an on/off switch. When the switch is off, electricity can’t flow through to power on the computer. When the switch is on, the switch allows electricity to flow through the computer system, bringing it to life. Some computers are always on…if electricity is on, the computer is on.
Almost every computer has a power supply, a component that takes wild and crazy electricity from the outside world and calms it down, supplying relaxing power to the rest of the computer. Some times the power supply is inside the computer. Sometimes it is outside.
Computers forget everything when they are turned off. Before a computer is turned off, a computer must save what it knew to storage, so that when it’s turned back on, it can load what it knew.
Computers that run on batteries (like laptops and smart phones) usually don’t have an internal power supply, because the battery produces naturally calm electricity.
However, the charger for a battery usually has a power transformer…that usb charger for a smart phone? The charger is calming down the wall electricity so that the smart phone battery will charge. In this sense, smart phones and laptops both have an external form of power supply.
The Computer Clock
When a computer is off, it is dead–it knows nothing and can remember nothing.
When a computer is turned on and has power, electricity will flow through the computer like water. The first thing the computer does is pass electricity through a crystal and some special circuitry, which fills up like a cup. When the cup gets full, it automatically empties itself. When empty, the cycle restarts, and it fills up again.
The instant the cup is completely empty, it acts like a clock going *TICK*.
When empty, the magical cup filling happens very, very quickly. Each time the cup is filled completely, it acts like a clock going *TOCK*.
Empty…*TICK*…full…*TOCK*…empty…*TICK*…full…*TOCK*, back and forth the internal clock of the computer swings, like a pendulum.
The computer designers know that in the time between tocks, a computer must get one cycle of instruction complete, or there will be a big time computer pileup.
All computers listen to the *TOCK*. Each time a computer hears a tock, it knows that it needs to do something. Tick Tock, Tick Tock….in that time, the computer will have done two things. This ticking and tocking, this clock, is what makes a computer, a computer: it is “computing” what to do, each Tock.
Computer clocks are incredibly fast, ticking and tocking three billion times a second or more. This speed is different across computers, and is known as the clock speed. 3 billion times a second is 3 Giga Hertz (GHz). Giga means billion, Hertz is a unit of measurement of ‘things per second’…or in scientific terms, cycles per second.
A 3Ghz computer is very fast indeed, meaning it is able to do at least 3 billion things…each second. The higher the speed, the faster, the better, the computer.
Because of the computer’s clock, the computer can tell that was recently turned on…it will recognize that it doesn’t remember anything, and hasn’t been told what to do. It’s memory is all a jumble. The computer knows: it needs to look at it’s firmware program.
When first turned on, the computer is hard wired to look at what to do by reading a special book — an instructional book — saved in special memory that is only available when the computers thinks it’s just been turned on. This book is called firmware. The style of book depends on the computer. Many times, in older computers, the firmware is known as BIOS: Basic Input Output System. Newer computers run firmware known as UEFI: Unified Extensible Firmware Interface.
Firmware is different then an operating system, because the firmware doesn’t save anything, or respond to you. All it can do is tell the computer what to do. The computer is hard wired to send fixed instructions, from the firmware memory, to the computer chip, the CPU.
These instructions are very specialized, and only work when nothing else is happening…only when the computer is first turned on. All the components of the computer are friends of the firmware, and what the firmware will do is go around and ask everyone hello, how are they feeling, are they ready to get started, etc.
When a computer is shutdown, then turned on, the firmware knows that it is doing what is known as a cold boot, and that it needs to do more double checking.
When a computer is rebooted, power is never completely lost. Firmware knows that it doesn’t have to look at closely at all its friends, and so it can speed the boot process. This is known as a warm boot.
That is why, sometimes, to fix a hardware glitch, if rebooting (warm boot) doesn’t work, it is important to try shutting down, then turning on, a computer…the cold boot check is more thorough, and might clear the problem.
Firmware is a program coded by the computer designers that tells the computer how to turn itself on. And to do this, it’s going to look and see…how was the computer setup before?
The first thing the firmware does is look at a special memory chip that would have remembered settings from the last time the computer was turned on.
This special firmware setting chip is waiting for the computer to be turned on, so it can tell the firmware chip what it remembered. That is it’s sole purpose. You can’t easily set these settings–they are inaccessible, typically, from the operating system, for your safety.
Remember when a computer is off, and power is gone, it loses all memory. One of the important things remembered is the current date and time, stored in a special chip called a Non-Volatile Random Access Memory (NVRAM) chip.
Before special firmware setting chips were included on computers, people would have to manually setup their computers each time the computer was turned on: manually setting the date, the time, and other important settings just for the computer to run. How lucky we are to have firmware setting chips remember that information for us!
After reading the firmware setting chip (including current date/time), the firmware gets to work. Sometimes when a computer is turned on, it’s memory, while jumbled, has echoes of what the computer was doing before the computer was turned off, and that’s not good. The firmware resets and initializes very specialized parts of its jumbled memory — known as registers — that is stored on the computer chip itself.
Registers aren’t RAM–they don’t store data or instructions. Instead, registers remember only numbers; registers are like cell phones for the CPU, firmware, and the firmware’s friends.
The second thing the firmware does is a POST: Power On Self Check.
The firmware begins asking the computer about itself, looking for its friends. Can I display? Can I beep? What else can I do? These questions are part of a list called Power Own Self Check, or POST.
When the firmware finds friends, it asks those friends to turn on and get ready for use. The monitor will suddenly turn on. Hard drives will power up. Computer speakers might beep, or play a sound. A fan may begin to whir at super high speed.
If a friend isn’t feeling well, the firmware stops. This is stopping is called a POST error. Hopefully, the POST error wasn’t with the graphics card, because then you might not know what the problem was. Sometimes, the POST error is so bad, the computer just turns itself off. Or worse, doesn’t do anything at all.
Inside the computer are special lights, inside the computer that blink. This way, if the computer setup is so bad, you have someway of figuring out what happened, although you would need some way to open the computer case.
It’s as if the computer is saying “I don’t know what you did, but it’s a hot mess, I quit.”
Sometimes, best friends are ok, but other friends aren’t well. The firmware will display a message, and many times, give you a chance to press a key (F12, or ESC, etc) to run another special program to change the firmware setting and try again.
Even smartphones have a firmware–it may run too quick to notice, but it’s there.
Once the POST is complete, the computer knows what it’s components are, knows which component’s are ready for action, and usually turns on the display. The firmware friends are all happy. The firmware program is almost done. The final step: the firmware tries to figure where to load it’s next program from.
After the firmware has initialized it’s components, it will try to find another program to take it from here–another special program called the bootloader.
Firmware settings tell the firmware the order in which it to look at it’s various parts for this program. This order is a very important setting.
Sometimes it will check the USB drive, the CD drive, then the hard drive. Other times it will do the reverse — check the hard drive, then cd drive, then USB drive. If a computer has a boot loader on the hard drive, checking everything else first can needlessly slow down the boot up process, so optimizing the boot order can be an important part of configuring a computer.
The boot order is set by entering a firmware setup screen. Usually, firmware loads a tiny program into memory from the hard drive, and asks that program to take over from here. That program is called a boot loader.
A boot loader is a program that runs after the firmware is done, and its job is to know where to find the operating system, then start it.
We should note that computers are filled with many divisions of labor…what looks like one giant complex thing might actually be many, smaller things, each one relatively simple in what it does. By splitting long, hard tasks into smaller, easier chunks, the engineers that build and program computers have an easier time getting it right–as well as fixing it, when it’s wrong.
While firmware comes from a chip that is hard for you to access, the boot loader comes from your hard drive. This means you can replace your boot loader, if for some reason you want to, whenever you like, with whatever you like.
Updating firmware, on the other hand, is a much dicier proposition. The firmware, to save cost, is very limited it what it can do–there isn’t a lot of room to have a complex firmware.
The boot loader can be a bit bigger, and a bit fancier. Not horribly big, but as big as it needs to be. Usually the smaller the better, to save time. It has one job to do, so it should do it well.
Before the boot loader streams the operating system into memory, it might look for keystrokes, or read a special part of the hard drive, looking for clues and settings as to how to load the operating system. Operating systems can be quite complex, and the boot loader can help the operating system running on computers with complex components. Start piling on graphics cards, audio cards, special processors–all the fun things that make a computer fun–and the operating system might need a hint or two. That’s what the boot loader does.
Note that even smartphones have a boot loader, it’s just highly specialized because the smartphone already knows what it is.
The boot loader’s primary job is to find the operating system kernel–the main program that makes a computer go–and load it into memory. It might also load other programs into memory that the kernel needs.
After enough programs are loaded into memory, and all the computer components are ready to go, the boot loader will send an instruction to the CPU chip: jump to the operating system, and continue take it from there!
Operating System Boot
The operating system boot will usually begin by loading even more programs into memory, running various prepratory self checks–maybe connecting to the internet, double checking the date/time, resetting graphics to a fancier mode, etc. If your screen blinks and redisplays, thats your OS at work. If you hear a fancy startup sound, that’s your OS at work.
Once an operating system is loaded, then the computer is ready for use!
Why does turning on a computer take so long?
The more general purpose a computer system is, the more time it has to spend to figure out what it has. Although the above can take as little as two seconds, it can take as long as a minute. The amount of time really depends on how optimized the boot process is for your computer.
A major chunk of the boot time is spent figuring out what is in a computer, as many computers can’t remember what was inside them, and then making sure what is inside is ready to go, then doing setup and initializiation–loading programs, connecting ot network, etc.
When building your own computer, you might want every self check, because you might be opening it up and replacing parts frequently. Or, you might decide to really stream line the boot process, because you know you won’t be adding anything. A 30 second boot process can be brought down to 3 seconds.
Devices, like tablets, smart phones and some laptops, are very closed–the designers can optimize the start up process to skip many of the checks: there is no need for the computer to check itself, because it can’t change. Their boot times seem near instant.
I hope the above explains why video game consoles, smart phones, tablets, lap tops and desktop workstations all need to be turned on. Some other time, we’ll take a look at turning a computer off.