When operating system is started, it must be available to the hardware. But how hardware knows that where is Kernel located and how it can load Kernel??
The process of starting the system by loading the Kernel in the memory, is called System Boot.
A small piece of code which locates the kernel and loads it into the memory, is called Bootstrap Program or Bootstrap loader. This program will start the execution of Kernel as well.
Although in some systems, a two step process is used, in which:
- In the first step, bootstrap program fetch a complex boot program from disk.
- In the second step, the program that is fetched by bootstrap, loads the Kernel.
When a CPU is re-booted, its instruction register is loaded with a pre-defined location and its execution is started. The bootstrap program is initially at this location. This program will be in the form of ROM, because the RAM is in un-known state at the startup. ROM is used because:
- It does not need any initialization.
- It cannot be easily affected by any virus.
Tasks Performed by Bootstrap:
Bootstrap performs a variety of tasks. Let’s have a look at some of them:
- It runs the diagnostics to determine the state of the system. If diagnostics pass, it will continue with the booting steps, otherwise not.
- It initializes all the aspects of the system.
- It starts the operating system.
System Boot in small Operating systems:
Some small handheld devices such as Mobile phones, PDAs and game consoles store the operating system in ROM. This approach is used for small operating systems and simple hardware. But there is a problem with this approach, if we want to change the bootstrap code, we will have to manipulate the ROM chips. In some systems, this problem is resolved by using EPROM. All types of ROM are also known as Firmwares. The characteristics of firmware falls in between the hardware and software.
A problem with firmware is that they are slower as compared to RAM. It has a solution too. Some systems store the operating system in firmware and when it has to executed, they loaded it in RAM.
System Boot in Large Operating systems:
For large operating systems such as Windows and Linux, the operating system is stored in disk and bootstrap is stored in firmware. In this approach:
- Bootstrap runs the diagnostics.
- Bootstrap has code which will read the small block from disk into the memory.
- Then, the code from this block will be executed.
- The program located in the boot block, will load the operating system in the memory and start its execution.
- Then, the bootstrap program will traverse the file system to find the Kernel.
- When Kernel will be found, it will be loaded in the memory and its execution will starts.
GRUB is an example of bootstrap program for Linux.