Booting the System | Komputasi | Suatu Permulaan

Chapter 9 Technicalities The previous chapters covered the classical operating system curriculum, which em- phasizes abstractions, algorithms, and resource management. However, this is not enough in order to create a working system. This chapter covers some more technical issues and explains some additional aspects of how a computer system works. Most of it is Unix-specific.

9.1 Booting the System

Obviously, if the operating system is running, it can open the file containing the op- erating system executable and set things up to run it. But how does this happen the first time when the computer is turned on? Based on the analogy of getting out of the mud by pulling on your bootstraps, this process is called “booting the system”. The basic idea is to use amplification: write some very short program that can only do one thing: read a larger program off the disk and start it. This can be very specific in the sense that it expects this program to be located at a predefined location on the disk, typically the first sector, and if it is not there it will fail. By running this initial short program, you end up with a running longer program. In the ’60 the mechanism for getting the original short program into memory was to key it in manually using switches on the front panel of the computer: you literally set the bits of the opcode and arguments for successive instructions in the PDP-8 in this picture, these are the row of switches at the bottom 176 Contemporary computers have a non-volatile read-only memory ROM that contains the required initial short program. This is activated automatically upon power up. The initial short program typically reads the boot sector from the disk. The boot sector contains a larger program that loads and starts the operating system. To do so, it has to have some minimal understanding of the file system structure. Exercise 136 How is address translation set up for the booting programs? Exercise 137 How can one set up a computer such that during the boot process it will give you a choice of operating systems you may boot? One of the first things the operating system does whan it starts running is to load the interrupt vector. This is a predefined location in memory where all the entry points to the operating system are stored. It is indexed by interrupt number: the address of the handler for interrupt i is stored in entry i of the vector. When a cer- tain interrupt occurs, the harwdare uses the interrupt number as an index into the interrupt vector, and loads the value found there into the PC, thus jumping to the appropriate handler of course, it also sets the execution mode to kernel mode. As a recap, it may be useful to review some of the interrupts we have seen in previous chapters, and some we didn’t, roughly in priority order: 177 type interrupt typical action panic hardware error emergency shutdown power failure emergency shutdown exception illegal instruction kill process privileged or undefined arithmetic exception kill process e.g. divide by zero page fault page in the missing page device clock interrupt do bookkeeping, check timers, reschedule disk interrupt wakeup waiting process, start new IO operation terminal interrupt wakeup waiting process trap software trap switch on requested service After setting up the interrupt vector, the system creates the first process environ- ment. This process then forks additional system processes and the init process. The init process forks login processes for the various terminals connected to the system or the virtual terminals, if connections are through a network.

9.2 Timers