Process of booting up a computer into an operating system involves several steps. Similar to all other things, computer also does require to go through some steps before it is properly setup to be used by end users. Let us examine other example. When we put our car key into the car's start ignitor, there are backend processes involved in getting the engine up and running. Start off by battery generating voltage to the spark plug the generate fire sparks within engine till the end of process of getting all engine's valve rotate up and down providing gasoline combustion to generate heat to power up the car. Well, that is for car and in this case we'll be looking more into the process of how does a computer boots up.
1. Introduction to Boot Process
Process of booting up a computer into an operating system involves several steps. Similar to all other things, computer also does require to go through some steps before it is properly setup to be used by end users. Let us examine other example. When we put our car key into the car's start ignitor, there are backend processes involved in getting the engine up and running. Start off by battery generating voltage to the spark plug the generate fire sparks within engine till the end of process of getting all engine's valve rotate up and down providing gasoline combustion to generate heat to power up the car. Well, that is for car and in this case we'll be looking more into the process of how does a computer boots up.
A computer does not start up like a car, or a chainsaw that requires you to pull a string to start using it. Similar to the process of starting a car, the process of a computer starting up involves series of steps or processes undertake by the system. This series of steps is called "booting". In computing, booting (or booting up) is the initialization of a computerized system. The system can be a computer or a computer appliance. The booting process can be "hard", after electrical power to the CPU is switched from off to on (in order to diagnose particular hardware errors), or "soft", when those power-on self-tests (POST) can be avoided. Soft booting can be initiated by hardware such as a button press, or by software command. Booting is complete when the normal, operative, runtime environment is attained (Wikipedia, Booting, 2016). In laymen's term, booting is a process of preparing to enter into the computer's operating system and made it ready for us the end users to interact with the computer.
An Operating system is the program that, after being initially loaded into the computer by a boot program, manages all the other programs in a computer. The other programs are called applications or application programs (CBOS2203 Operating System, 2005, p. 18). Refer to the diagram below for a quick illustration on how does a computer boots up.
Basically, when we turned on the computer, the BIOS will first initialize itself and do a self-test and during this phase we called it as Power-On Self Tests (POST).
After that, the computer will start communicating with hard drive's boot program, or technically known as Master Boot Record (MBR) from the boot sector of the active partition to load the Bootloader. And what is a boot loader? A boot loader is a computer program that loads an operating system or some other system software for the computer after completion of the power-on self-tests; it is the loader for the operating system itself. Within the hard reboot process, it runs after completion of the self-tests, then loads and runs the software. A boot loader is loaded into main memory from persistent memory, such as a hard disk drive or, in some older computers, from a medium such as punched cards, punched tape, or magnetic tape. The boot loader then loads and executes the processes that finalize the boot. Like POST processes, the boot loader code comes from a "hard-wired" and persistent location; if that location is too limited for some reason, that primary boot loader calls a second-stage boot loader or a secondary program loader (Wikipedia, Booting, 2016).
Depending on which operating system, from here onwards everything will be handled by the operating system's Bootloader. For example, if we are to boot to DOS system, then system will look for "io.sys" file on the drive folder of the active partition while if we are to boot to Windows Vista, 7, 8 or 10 then the system will look for "bootmgr.efi" or "bootmgr.exe". Older Windows version uses "ntldr.dll" while most Linux system uses "grub.conf".
As this process may varies depending which operating system, I will not discuss any of the Bootloader any further as further details will be explained later when answering question two of this assignment question..
Not all computer has a similar boot process as explained above as it depends on the computer's motherboard features and functionalities. I know for a fact that old motherboards do not have SMART features therefore may bypass some of the POST tests, and some may or may not contains Unified Extensible Firmware Interface (UEFI) which may have a different booting process completely as it supports fast computer boot process and there is even some motherboard will have features like express gate functionality allowing user to switch between multiple BIOS profile we have.
However, explanation above should suffice to serve as a basic guideline as almost all motherboard's share similar boot process.
2. Main Components of Boot Process
As discussed before, when a computer boots up, it will undergo several processes. As there are several types of operating system, there are some basic processes that almost all computers will run through irregardless of the difference of operating system. For a better explanation, I will be discussing the difference between two operating systems which is Windows and Linux.
2.1 – Overview of Operating Systems
You may refer Figure 3 and 4 above and may recognize the logo. Both is a completely different operating system and have different architecture completely. I am pretty sure that you have at least seen this logo before. Let's discuss a little bit of background first for both of these Operating System.
Microsoft Windows (or simply Windows) is a meta family of graphical operating systems developed, marketed, and sold by Microsoft. It consists of several families of operating systems, each of which cater to a certain sector of the computing industry. The famous or commonly used by people nowadays are Windows 7, Windows XP, Windows 8 and Windows 10.
Linux on the other hand was originally developed as a free operating system for personal computers, but has been ported to more computer hardware platforms than any other operating system. For examples, mobile phones nowadays running on Android is actually based on Linux operating system. Linux is also the leading operating system on servers and other big iron systems such as mainframe computers and virtually all fastest supercomputers (Wikipedia, 2016).
2.2 - Basic Input Output System (BIOS)
Refer back to the Figure 2 in page 2, the very first process of a computer boots up is Basic Input Output System (BIOS). When we switch on the computer, the Central Processing Unit (CPU) will initializes itself first which is triggered by series of clock frequencies generated by system clock. During this phase, the CPU will look into the system's Basic Input Output System (BIOS) for its very first instruction on what to do. These instructions are stored inside the motherboard's Read Only Memory (ROM) BIOS.
The very first sets of instruction given is Power On Self-Test (POST) and this process is executed in a predetermined memory address. According to (Wikipedia, 2016), "A power-on self-test (POST) is a process performed by firmware or software routines immediately after a computer or other digital electronic device is powered on. The results of tests run by the POST may be displayed on a panel that is part of the device, output to an external device, or stored for future retrieval by a diagnostic tool. Since a self-test might detect that the system's usual human-readable display is non-functional, an indicator lamp or a speaker may be provided to show error codes as a sequence of flashes or beeps. In addition to running tests, the POST process may also set the initial state of the device from firmware.".
System will check the condition of the CMOS battery. If the CMOS battery is dead, system will prompt error indicating the CMOS Battery failed.
When it fails, normally some of the BIOS settings are not stored, for example any custom CPU clock frequency, date/time and other adjustable settings. When battery fails, BIOS will restore back to the original factory settings.
Next, POST will do a quick test on the CPU and RAM configuration. For most common users, people will leave all settings to automatic, which means all settings are auto populated by the motherboard as system will try to configure itself based on the type of processor used.
However, for some advance users such as myself who does overclock processor, during this phase POST will began to test our CPU and RAM configuration. POST will test out FSB, clock multiplier, dram frequency and cycle rate. Normally, POST will only conduct a quick and basic tests as comprehensive tests of the overclock can only be done using different software such as Prime95, Memtest86 and others.
POST will now start to detect all connected drives to the motherboard. This includes Hard Disks, CD/DVD drives, USB drive and others.
If SMART (Self-Monitoring, Analysis and Reporting Technology) functionality is enabled, then additional test will be executed to quickly analyse the computer's hard disk. If a drive is about to give problem, SMART will detect and will throw errors to the screen alerting us that the hard disk might be having problem.
2.3 - Master Boot Record
After system have successfully identified all the drives, as defined by whatever configuration we have in BIOS, BIOS will look at the first sector from the hard drive (or removable storage such as CD/DVD/USB) that have a 512-byte area and copies the information to the specific RAM location. This information is known as Master Boot Record (MBR) and loads it at hexadecimal address 7C00 of the RAM.
Every hard disk has an MBR, and it contains several important pieces of information. Within the MBR, it contains partition table, boot signature and bootstrap code. From the MBR, system will be able to determine which is the active partition table.
2.4 - Partition
A partition is a logically independent section of a hard disk drive. For example, a hard disk of 10 Gigabyte of storage can have 6 sets of partition and each partition may have a different size. Referring to Figure 6 below, the hard disk is being partitioned into six partitions and each partition have a different storage size allocation.
An active partition is a partition that contains the operating system that a computer attempts to load into memory by default when it is started or restarted. Without an active partition available, system will throw error as per Figure 7 below.
2.5 - Bootloader
Depending on which operating system, from here onwards everything will be handled by the operating system's stored procedure or commonly known as Bootloader. For example, if we are to boot to DOS system, then system will look for "io.sys" file on the drive folder of the active partition while if we are to boot to Windows Vista, 7, 8 or 10 then the system will look for "bootmgr.efi" or "bootmgr.exe". Older Windows version uses "ntldr.dll" while most Linux system uses "grub.conf".
2.5 – Windows Bootloader
Windows uses either NTLDR which is short for NT Loader or BOOTMGR which is short for Windows Boot Manager. Refer table below for the types of Windows Bootloader.
IO.SYS |
Older windows such as Windows 95, Windows 98, Window ME are a hybrid OS of DOS and Windows when it comes to bootloader. (except Windows 3.11 which is not an OS, but it is an application only) |
NTLDR |
Windows NT, Windows XP |
BOOTMGR | Windows Vista, Windows 7, Windows 8 and Windows 10 |
In effort to reduce the word counts for this assignment, I will only be discussing about NTLDR. NTLDR runs directly from hard drive usually and can load both Windows operating system or any other operating system. With that being said, this makes the bootloader provides an option for users to have dual-booting options.
When the boot loader started, first it will try to access the file system on the boot drive. If your drive is not accessible, then it will not boot up. After the drive have been mounted and prepared, Windows will search for hibernation file which is "hiberfil.sys". What is hibernation? It is a semi-sleep mode that stores some of the RAM files to the hard drive. As we all know that RAM will discharges its memories the moment your computer shuts down, Windows will save some of the RAM memories into the hard drive for faster boot up process. If the hibernation file is not found, it will look into the file "boot.ini" to continue the system initialization.
From the "boot.ini" file, bootloader will look for the list of operating system to be booted up. From this file itself, we can set to have multiple boot options. For example, if I want to have Linux and Windows available on my system, just edit this file and add linux GRUB loader. Refer the highlighted line in the table below for example of how this can be done.
multi(0)disk(0)rdisk(0)partition(5)\WINDOWS="Microsoft Windows XP Professional" /NOEXECUTE=OPTIN /FASTDETECT
multi(0)disk(0)rdisk(1)partition(1)\WINDOWS="Microsoft Windows XP Professional (Safe mode)" /BASEVIDEO /SOS
c:\CMDCONS\BOOTSECT.DAT="Microsoft Windows XP recovery console" /CMDCONS
c:\linux.bin="Grub (loader)"
Remember that this only works for NTLDR bootloader and don't deduct my assignment points if this does not work on your computer. As mentioned before, newer windows use BOOTMGR bootloader instead of NTLDR.
2.6 – Windows Initialization
Assuming we choose Windows to boot into, next step is that Windows will start to initialize itself. If you press F8 during the boot process, a menu will be displayed showing all available advance boot options.
Advance boot options offers custom start up options such as Safe Mode, Boot Logging, enabling low-resolution mode and others. This options are very useful when it comes to troubleshoot any hardware or software issues if we are not able to boot successfully to the Windows.
Next, it will start to load the kernel. Kernel are essential files such as "ntoskrnl.exe", "hal.dll", "bootvid.dll" and more. Often, these files are mostly associated with the drivers for each hardware components resides in your computer. There are lots of kernel and I am not going to discuss one by one as it varies, depending on what you have on your system. However, basic Kernel such as "ntoskrnl.exe" is always loaded up in any Windows based computer as it is one of the components of Windows.
Once done, then a session manager will start and will start to initialize Windows log on page. During this part, if you have any security settings set up in your computer, then you need to select which user account to login to and enter password associated with that user account. Most office computer will have these controlled by a Domain's Active Directory (AD) control, whereby all the user account resides in the domain's AD instead of local AD.
After you have successfully login, then the last step is to load up all of the start-up items such as loading applications and etc. Refer Figure 9 below for sample of applications that will start-up on Windows boot.
You can easily change this by pressing "START" and "R", and type "msconfig" and "ENTER". You will get the dialog box above and this method works on all Windows platform (except Windows 3.11. newer Windows may have different layout).
Well, that's about it for Windows and let's move on to Linux.
2.8 – Linux Bootloader
Different than Windows, Linux uses GRUB or short for Grand Unified Bootloader as it's bootloader program. Newer Linux uses GRUB2 instead such as latest Ubuntu, Android 4+ and so on. Bootloader may differ between different CPU architecture. Have you ever heard of x86, x64, ARM processors? These are the types of processors available and all of these processors are able to be used with Linux. ARM based processors are processors commonly used by mobile phones such as Snapdragon 820, while x86 and x64 are common desktop processors such as Intel I3, I5 or I7. For this assignment paper, I will focus only on desktop computing which is x86 or x64 based processors.
GRUB is being stored in the MBR and consumes less than 512 bytes in the partition. It is a very small size indeed. The file is located at "/etc/grub.conf" of the active partition.
Generally, there are three phases for GRUB to start loading the kernels.
Phase 1:
• The primary boot loader takes up less than 512 bytes of disk space in the MBR - too small a space to contain the instructions necessary to load a complex operating system.
• Instead the primary boot loader performs the function of loading either the phase 1.5 or phase 2 boot loader.
Phase 1.5:
• Phase 1 can load the phase 2 directly, but it is normally set up to load the phase 1.5.
• This can happen when the /boot partition is situated beyond the 1024-cylinder head of the hard drive.
• GRUB Phase 1.5 is located in the first 30 KB of Hard Disk immediately after MBR and before the first partition.
• This space is utilized to store file system drivers and modules.
• This enabled Phase 1.5 to load Phase 2 to load from any known location on the file system i.e. /boot/grub
Phase 2:
• This is responsible for loading kernel from "/boot/grub/grub.conf" and any other modules needed
• Loads a graphic user interface (GUI), for example splash image located at "/grub/splash.xpm.gz" with list of available kernels where you can manually select the kernel or else after the default timeout value the selected kernel will boot
• This is what being edited by most of the "ROM Cooker". Have you ever heard of people customizing their android based mobile phone to change some settings by applying custom ROM? Head up to XDA Developer website and look for custom rom there. I myself have contributed several customs rom as well for mobile phone.
2.9 – Linux Initialization
Next, load up the kernels! Similar to Windows, Kernel is essential files needed to be loaded up as it serves as files related to your hardware components. Some may say this is the heart of the operating system and is responsible for handling all of the system processes.
When it comes to Linux, all kernels are completely different than Windows. You cannot load up Windows kernel with Linux or vice versa. It is completely different architecture even though you are running on a same hardware. Kernel is loaded in the following stages:
Kernel as soon as it is loaded configures hardware and memory allocated to the system. |
Next it uncompresses the initrd image (compressed using zlib into zImage or bzImage formats) and mounts it and loads all the necessary drivers. |
Loading and unloading of kernel modules is done with the help of programs like insmod, and rmmod present in the initrd image. |
Looks out for hard disk types be it a LVM or RAID. |
Unmounts initrd image and frees up all the memory occupied by the disk image. |
Then kernel mounts the root partition as specified in grub.conf as read-only. |
Next, it will start to run the "init" process. System will look for the file at "/etc/inittab" file to decide which level of Linux to be run. Refer below for the available levels to be run.
0 | Halt |
1 | Single User Mode |
2 | Multiuser mode (without NFS) |
3 | Full multiuser mode |
4 | Unused |
5 | X11 |
6 | Reboot System |
Similar to Windows, the final stages are to load up the start-up items for the Operating System. However, different term is used here as we called it as "Run Level programs". During the Linux boot, we might see something like "starting email client", or "foldermount is mounting images" or "supersu is running" and others. These are examples of applications loaded up and is defined by the run level.
Under the "/etc/rc.d/rc*.d/" directories, we can see programs that start with "S" and "K". Those that are listed with "S" are applications that will start-up during boot while "K" stands for kill means application that will be killed off during shutdown. For example, we can set "S10apache2" which points to "/etc/init.d/apache2", where as "S" stands for start-up application with priority number 10 and running at runlevel 2. To easier explain this, refer table below.
S |
Start-up |
10 | Priority Level. It means that this will start on the 10th of the list of start-up items. |
Apache | Name of the program (actually it's a symlink) |
2 | Init run level. 2 means multiuser mode without NFS. |
Once all application is loaded up, then we as an end-user are free to use. That is all for Linux. Bear in mind that this is a general process of booting up a Linux as they are many variants, architecture and different bootloader as well. However, this information is enough to serve as a basic guideline on Linux's booting processes.
3. Description on Process State
The CPU executes a large number of programs. While its main concern is the execution of user programs, CPU is also needed for other system activities. A process is a program in execution. Typically, a batch job is a process. A time-shared user program is a process. A system task, such as spooling is also a process (CBOS2203 Operating System, 2005, p. 38). Basically, the operating system is responsible for managing activities in connection with process management.
Referring to the Figure 10 above, it is a quick overview of a certain process is being managed by the operating system. There is no description of what process is this, so for the sake of providing an example, let's assume it's a process of playing a video file in a computer.
When we play a video on a Windows-based computer, what we normally do is just double clicking the video file and the video is will be displayed on the screen successfully.
3.1 – CREATE State
The moment we double clicked on the video file; a new process has been created to play the video. When a process is first created, it will be marked as "CREATE" or "NEW" state. During this state, the process will wait for the admission to be "READY", as it will seek out for approval, or check with process scheduling or others. Normally, in most desktop computer the admissions will be approved instantly.
In this case, when we double click the video file, it is instantly admitted to "READY" status after OS have checked all necessary prerequisites are met. For example, checking whether the audio device is configured and ready, or video codec are available and other factors, depending on the video software prerequisites. At the same time, OS will also check if CPU or RAM resources are available, otherwise it will clear up some resources from other applications and during this time you will faced a slight slow-down on your computer. Most of the time, you won't have noticed this as CPU nowadays are very fast opening up a video files. Screenshot below
3.2 – READY State
Once loaded up successfully, the player will be displayed in-front of you. Some video players will play the video file automatically, therefore it goes straight to "RUNNING" process state. Refer to Figure 11, a screenshot showing that the video software is loaded up and is in "READY" state to play the video.
3.3 – WAITING State
Let's say that we are running on a very old desktop computer, with lack of processor power and ram. This means that the resources are very limited. At the same time, we have several applications opened up on this very old computer, utilizing lots of resources already in terms of both CPU and RAM. We will have noticed a slight slow-down when opening up the video player.
In multiprogramming, some processes run at all times such as anti-virus, windows-based applications and components and others. In the example above, some processes are still being run in the background, utilizing CPU and RAM resources. OS will maximize CPU utilization of time sharing to switch usage to the desired application which in this case is the video player.
Referring to Figure 12 above, Windows Process Schedule will manage it applications and put to queues for some other application by applying a Process Control Block (PCB). Basically each Scheduling Queue is to:
• maintains information of all ready processes for CPU/Devices. A sample queue is shown in Figure 12
• A queue is normally maintained as a linked list. Its header contains the pointer to the first PCBs and the tail contains pointers to the last PCBs in the list.
• Each PCB has a pointer field that points to the next process in the queue.
With that being said, the state "WAITING" will be applied and OS will apply PCB to other application (depending on the linked list) in order to free up some resources for the video software to be opened. Once enough resources are available, OS will unblock the PCB and admitted the applications to "READY" state.
3.4 – RUNNING State
Once the video software is opened up, it is in "READY" state. Once the user clicks on the play button the play the video file, system will dispatch order to the system to run the process which in this case, to play the video file. Once the video file is being displayed, the process state will be marked as "RUNNING" state.
However, if there are any issues with the video such as file corrupted or other issues, then system will apply PCB and the process will be in "WAITING" state first to logs necessary log files for the error, and goes back to "READY" state, awaiting command from the end user of what to do next. During this state, we can see some error message on the screen saying there are problems with the video file and unable to be played.
3.5 – TERMINATED State
When we finished with the video, either enjoyed watching the video successfully or was prompt with errors saying corrupted video file or any other issues, we will close the video application file by clicking the "X" button on the window. Once this is done, OS will send instruction to terminate the application process. This process is called "TERMINATED" state, but is still being cached in the memory until being cleared by the OS by restart or memory re-write by other processes.
3.6 – Terms Used in Process States
Refer Table below for quick overview of all terms used during the process states explanations.
CREATE |
A process state that system creates a new process |
Admitted | During creation of new process, it is being admitted to the system to be ready |
READY | A process state that is ready to be executed |
Block | Also called as PCB. Block a process from RUNNING and put it to WAITING |
WAITING | During this process state, system is busy managing resources |
Unblock | Once system is no longer busy, it will unblock and admitted to READY |
Scheduling dispatch | A signal being sent to application to execute/run |
Interrupt | Interrupts the RUNNING process back to READY state |
RUNNING | Process state of application being run |
Exit | A process to terminate the application |
TERMINATED | Process is completely terminated |
References
1. GoLinuxHub. (June 2016). Step by Step Linux Boot Process Explained In Detail. Von GoLinuxHub - Sys Admin Tutorial Guide: http://www.golinuxhub.com/2014/03/step-by-step-linux-boot-process.html abgerufen
2. Prof Dato' Dr Mansor Fadzil, A. P. (2005). CBOS2203 Operating System. Malaysia: open University Malaysia.
3. Wikipedia. (June 2016). Booting. Von Wikipedia - The Free Encylopedia: https://en.wikipedia.org/wiki/Booting abgerufen
4. Wikipedia. (June 2016). Linux. Von Wikipedia - The free encyclopedia: https://en.wikipedia.org/wiki/Linux abgerufen
5. Wikipedia. (June 2016). Power-On Self-Test. Von Wikipedia - The Free Encylopedia: https://en.wikipedia.org/wiki/Power-on_self-test abgerufen
Few years back, i was given an assignment paper for my studies on Operating Systems. The assignment paper was about an in-depth discussion about System Boot Process and Operating System Initialization. I have decided to publish my written articles here after one year from the assignment date. This is due to avoid any plagiarism issues that i might encountered if i publish this earlier than that.
You may download the published assignment paper here.