What exactly happens when you press the button on the side of your computer? I mean what exactly happens?



At a basic level, the very first thing to happen when you push the power button is of course that a circuit is completed. The circuit connects with the computer’s power supply starter. The power supply springs into action and sends power around a number of other circuits. Most of these, such as the fan, are extremely simple, but the most important one, the BIOS chip, is a mini computer in its own right.

The BIOS chip is responsible for locating everything else and telling each component to begin. The way that it actually operates is similar to the CPU (the central processing unit, the ‘brain’ of the computer that issues instructions to the rest of the components and does most of the calculations). The BIOS receives a burst of electricity which first goes to its ‘program counter’.  This is a set of 1s or 0s that send the electricity to copy the correct instruction from the BIOS’s ‘program’. Once the instruction is copied to the hardware can execute the instruction, the program counter increases by one. A fixed while later, the BIOS receives another burst of electricity and the process repeats. The BIOS follows this brief set of instructions to initialise systems such as the RAM, interrupt and DMA controllers, the graphics card, the keyboard and mouse and various kinds of storage. As each item is checked, the BIOS sends us the first piece of output, a few words on the display.

Bootstrap loader

The job of the BIOS is nearly done. Computers in the early 90s used the BIOS every time the keyboard was used but nowadays we hand over to a piece of the operating system called the bootstrap loader. Perhaps you have heard of a ‘bootable’ drive? The BIOS searches through all of the various types of storage attached to the computer to find one that claims to be bootable. To understand the next stage, we need to understand a file system.

No matter if its a USB stick or a massive hard drive, the point of it is to store a very long sequence of 1s and 0s. You give it an address (a set of 1s and 0s) and it gives you back the 1s and 0s at that address. In fact, the 1s and 0s are usually grouped together in groups of 8 called bytes. So the byte at address 00000000 determines whether or not it is a bootable drive. If it is, the CPU begins to work.

The CPU reads instructions much like the BIOS. The specific type of instruction that the CPU understands is described by a standard called x86.  One of the instructions in x86 is called a jump, which jumps to another place on the drive to continue execution. After passing to the CPU, the first instruction read is the next byte on the storage device and is usually a jump instruction. The place it jumps to is the beginning of a procedure that is part of the operating system know as the Bootstrap Loader.

The primary job of the Bootstrap Loader is to load the main part of the operating system (the kernel) into the computer’s fast access memory and set the CPU to begin to run it. All of these instructions are in a reserved part at the start of the storage device called the ‘Master Boot Record’.

The kernel’s first moments are spent in a very similar way to the BIOS, looking at all of the things connected to the computer’s motherboard (the circuitry that joins all of the other parts together). In the old days, this would be accompanied by a stream of scrolling text as each system is verified. Now there is generally a logo over the top. Having got the kernel fully up and running, the operating system checks that the rest of the disks are okay.

File System

How are files are stored on the hard disk? Operating actually store a single file in several ‘clusters’ which are roughly 1000 bytes each. Assuming a ‘fat’ type file system, let’s go through the process of looking up a file: 

The Master Boot Record (the reserved space at the start of the disk) contains information about the partitions of a disk (a partition is a distinct portion of the storage space – for example two partitions allow two different operating systems to run on the same hard drive without interfering with one another). Specifically, the last 64 bytes of the Master Boot Record are four ‘partition entries’. The partition entries contain the address to the start of the partition.

At the beginning of a partition is ‘volume ID’, which contains the address of the root directory. Each directory contains a list of files or directories.  The subfiles are checked in turn to see which matches the current top level of the file’s path.


Now the kernel is up and running, it passes control to a program. The kernel still has several jobs to do though. It makes it as easy as possible for running programs to access hardware. It also allows several programs to run simultaneously (it actually does this by switching rapidly between each program in turn).


One thought on “Booting Up

  1. Pingback: Setting the Tone of Your Game | The CogMob Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s