Computer Science Tutorial
Computer Booting sequence
Booting is the process of starting a computer from powerless state to loading the operating system kernel into memory. The complete process can be broken down into following sequences.
- User presses the power button.
- CPU performs a jump operation to a predefined address. This jump instruction remains hardcoded in to the hardware.
- The predefined address points a location in ROM that contains another program written in low level language. This program is called Bootstrap program or BIOS.
- The Basic Input Output System(BIOS) then performs some hardware check. This hardware check is called Power on self Test(POST).
- If POST succeed then BIOS goes on to search for MBR on the partition table otherwise computer startup fails.
- Master boot record(MBR) finds the operating system kernel and starts loading the OS kernel and transfer it's control to operating system.
There are two types of boot.
- Hard boot : If computer is in power off state and user presses the power button on. Then this booting is called Hard boot or cold boot.
- Soft Boot : If computer is restarted using shut down command in operating system. This is called warm boot or soft boot. When user reboots computer, the hardware does not completely go into power off state. Only OS is restarted. In certain condition soft boot may not work if computer shows some special kind of error. In that case we need hard boot. Press the power button for 5 seconds and let the computer go power off completely and then start it again after some time.
The soft boot is often called reboot or restart. Hard boot and soft boot are very much similar and both clears system RAM but soft boot may not clear system cache. Additionaly soft boot also does not perform power on self test.
Booting sequence Explained:
When user presses the power button, every hardware compnent receives a electrical signal goes to power on state. CPU also receives the power and comes back to life. CPU registers are initialised. At this point of time one of CPU register, Instruction Pointer was loaded with an jump instruction. This JUMP instruction remains hardcoded in the hardware. CPU executes this instruction and jumps to the location given by the instruction. This new location points to ROM which is a fixed address, that means everytime jump instruction is executed CPU jumps to the same memory location in ROM.
In this location a program written in low level language is stored which is called BIOS. This is the place where for the first time hardware(CPU) meets with software(the BIOS). Basic Input Output system(BIOS) performs some hardware check. This hardware check is called Power on self test(POST). POST is a kind of diagnostic test for hardwares. If all the hardware components pass this test, booting goes to next stage.
At this stage if no default disk has been set by the user, BIOS ask for the disk from which user wants to load the operating system. When user selects the disk, BIOS tries to load the MBR(Master Boot Record) from the disk into the RAM and hands over the control to MBR. At this point of time RAM is loaded into the RAM for the first time.
MBR is also a short low level code stored in the first 512 bytes of the disk. Out of this 512 bytes, first 446 bytes contains a short bootstrap code also known as Stage 1 bootloader. The next 16*4 = 64 bytes contains partition table. There can be maximum of four partition each takes 16 bytes. Out of this four partition only one partition remain marked as active partition. The job of the stage 1 bootloader is it searches for active partition in the partition table. If no active partition is found booting halts giving error message on the screen. The stage 1 bootloader now loads another bootstrap code from the active partition and handed over the control to it.
The new bootstrap code which is generally called stage 2 bootloader, is also stored in the first 512 bytes of the partition where the code is stored. The second stage bootloader actually loads the actual boot loader file. The actual bootloader is actually a file which stored in the active partition and can take several sectors in the partition. It's larger in size. This final bootloader file is not stored at a dedicated offset within the partition unlike previous bootloaders. The final bootloader file is actually a program written in high level language but previous bootloaders were low level code.
This final bootloader now presents the user with a list of installed OS within the disk. When user selects an OS, respective kernel starts loading into the RAM, with this the booting process ends.
BN Computer Academy
All Rights Reserved