The Kernel Execution System Startup

The system has to learn enough from the ROM to be able to access a disk to continue the bootstrap program, but it still assumes a simple flat data structure on the disk. A complex disk data organization such as the UNIX filesystem data structure is still too complicated for the system at this stage; more learning is needed to deal with a filesystem. That is why the rest of the bootstrap program is stored in a special part of the disk known as the boot partition sometimes also known as the boot segment. The main characteristic of the boot partition is its easy access and flat data structure, so the system is able to continue with the bootstrap program execution, and further learning. The ratio of the percentage of the bootstrap program stored in the ROM versus the disk boot partition varied through time. In the early days of UNIX when only low capacity, expensive ROM was available, the first part of the bootstrap program was reduced to the bare minimum size. Today, systems include high−density ROM sufficient to store quite sophisticated bootstrap programs; this makes boot partitions less important, although they are still a part of every system startup. Once the bootstrap program is completely executed, the system is knowledgeable enough to continue with the kernel execution. Traditionally UNIX presents the only OS running on underlying hardware; and traditionally this is a proprietary hardware for that UNIX flavor. This fact makes a booting process unique and quite straightforward. However, once PC hardware also became common in the UNIX arena, a more flexible booting, with UNIX as one of several choices, emerged as a preferable system characteristic. Linux is an example. On the Linux platform, the three most common booting mechanisms are: To boot Linux from the floppy, and leave hard drive for other OSs • To use the Linux loader LILO, the most common case • To run Loadlin, an MS−DOS program that boots Linux from within DOS • What is exceptional with LILO is the possibility of configuring this loader in different ways to match different needs; multiple−choice booting, including a non−UNIX startup, is also possible. The configured loader should then be installed in the boot sector of the first disk, known as MBR master boot record. When the system is started, the PC BIOS transfers control to MBR and triggers a corresponding LILO booting. Linux provides an easy LILO configuration through its etclilo.conf configuration file, and the command lilo for its installation as MBR.

4.2.2 The Kernel Execution

The bootstrap program is responsible for loading the UNIX kernel into the system memory. The kernel image, originally named unix under System V, or vmunix under BSD, is intentionally located in the root filesystem, because the root filesystem is the first filesystem the system mounts to access data. Mounting is a UNIX−specific procedure that makes data on the disk accessible. We discuss this issue in great detail in following chapters. In the past, the kernel image was located in the root directory for easier access, but today, it usually resides in a separate subdirectory. We do 89 The kernel manages all system hardware; all hardware drivers are part of the kernel, and the only OS access to the system hardware is through the kernel. Therefore the system hardware will be available upon the completion of this phase. Once control passes to the kernel, it prepares itself to run the system by initializing its internal tables and completing the hardware diagnostics that are part of the boot process. The level of diagnostics implemented varies from one UNIX flavor to another. At the very end, the kernel verifies the integrity of the root filesystem and remounts it, and starts three programs that create three basic processes. Two of them, named kernel processes, function wholly within the kernel in the kernels privileged execution mode. They are actually portions of the kernel itself, only dressed like processes for scheduling reasons. On BSD systems, the two processes are: Swapper process 0, responsible for the swapping — to schedule the transfer of whole processes between the main system memory and a mandatory swap partition on the primary disk when system resources are low 1. Pagedeamon process 2, responsible for supporting the memory−management system regarding paging — a regular transfer of data in the pages between the main system memory and the disk 2. On System V systems, the processes are named differently: sched for the process 0, while the process 2 is replaced with various memory handlers. The third process created by the system is the init process process 1, which performs all administrative tasks during the system startup and shutdown. The init process is an extremely important process that enables the creation of all subsequent processes in UNIX a process can be created only by another parent process. The init process has the PID=1, and it is the ancestor of all subsequent UNIX processes and the direct parent of each users login shell. In the case of diskless workstations, the procedure is slightly different. Obviously, the kernel cannot be read from a nonexisting root filesystem; therefore, it must be downloaded from the network. Further kernel activities are adapted to the diskless environment. The kernel is quite verbose and it prints messages on the console that report on the current execution status, total memory used and free, and some other information. However, the information reported varies among different UNIX flavors.

4.2.3 The Overall System Initialization