Operating Systems – CSCI 402
3.5 Booting
1
321 0
Copyright ý . Systems – CSCI 402
Boot
Came from the idiomatic expression, “to pull yourself up by your bootstraps”
without the help of others it¡¯s a difficult situation
In OS
load its OS into memory
which kind of means that you need an OS in memory to do it
Solution
load a tiny OS into memory
known as the bootstrap loader
then again, who loads this tiny OS into memory?
how about first loading a tiny bootstrap loader?
2
321 0
Copyright ý . DP-8
Operating Systems – CSCI 402
toggle switches
How about manually put into memory a simple bootstrap loader?
approach taken by PDP-8
“toggles in” the program
read OS from paper tape
321 0
3
Copyright ý . Systems – CSCI 402
PDP-8 Boot Code
07756 6032 KCC
07757 6031 KSF
07760 5357 JMP .-1
07761 6036 KRB
07762 7106 CLL RTL
07763 7006 RTL
07764 7510 SPA
07765 5357 JMP 7757
07766 7006 RTL
07767 6031 KSF
07770 5367 JMP .-1
07771 6034 KRS
07772 7420 SNL
07773 3776 DCA I 7776
07774 3376 DCA 7776
07775 5356 JMP 7756
07776 0000 AND 0
07777 5301 JMP 7701
4
321 0
Copyright ý . Systems – CSCI 402
VAX-11/780
5
321 0
Copyright ý . on floppy disk (the bootstrap loader) would handle:
disk device
on-disk file system
it needs the right device driver
it needs to know how the disk is setup
what sort of file system is on the disk how the disk is partitioned
a disk may hold multiple and different file systems, each in a separate partition
321 0
Operating Systems – CSCI 402
VAX-11/780 Boot
Separate “console computer”
LSI-11
hard-wired to always run the code contained in its on-board read-only memory
then read boot code (i.e., the bootstrap loader) from floppy disk then load OS from root directory of first file system on primary disk
6
Copyright ý . Unix
Configuring the OS
OS statically linked to contain all needed device drivers
device drivers were statically linked to the OS
all device-specific info included with drivers
disk drivers contained partitioning description
therefore, the following actions may all require compiling a new version of the OS:
adding a new device
replacing a device
modifying disk-partitioning information
Operating Systems – CSCI 402
7
321 0
Copyright ý . S statically linked to contain all needed device drivers
at boot time, OS would probe to see which devices were present and discover device-specific info
partition table in first sector of each disk
Even later Unix
allowed device drivers to be dynamically loaded into a running system
Operating Systems – CSCI 402
Later Unix
Configuring the OS
8
321 0
Copyright ý . Systems – CSCI 402
IBM PC
9
321 0
Copyright ý . Cheng
although MS-DOS was distributed in binary form only
large market for peripherals, most requiring special drivers how to access boot device?
how does OS get drivers for new devices?
Operating Systems – CSCI 402
Open architecture
Issues
10
321 0
Copyright ý . Systems – CSCI 402
The Answer: BIOS
Basic Input-Output System (BIOS)
code stored in read-only memory (ROM) configuration data in non-volatile RAM (NVRAM)
such as CMOS
including set of boot-device names
the BIOS provides three primary functions
power-on self test (POST)
so it knows where to load the boot program
load and transfer control to boot program provide drivers for all devices
Main BIOS on motherboard
supplied as a chip on the “motherboard”
contains everything necessary to perfrom the above 3 functions additional BIOSes on other boards
provide access to additional devices
11
321 0
Copyright ý . Systems – CSCI 402
POST
On power-on, CPU executes BIOS code
located in last 64KB of first megabyte of address space
starting at location 0xf0000
CPU is hard-wired to start executing at 0xffff0 on startup
the last 16 bytes of this region jump to POST
POST
initializes hardware counts memory locations
by testing for working memory Next step is to find a boot device
the CMOS is configured with a boot order
Next step is to load the Master Boot Record (MBR) from the first sector of the boot device, if it¡¯s a floppy/diskette
or cylinder 0, head 0, sector 1 of a hard disk (Ch 6)
321 0
12
Copyright ý . Systems – CSCI 402
Getting the Boot Program
Partition 1
Partition 2
Partition 3
Partition 4
Partition Table
Boot Program
Magic Number
64 bytes
446 bytes
the BIOS program loads and jumps to the boot program
the rest, of course, depends on what¡¯s in the boot program
e.g., MS-DOS, Linux
321 0
2 bytes
Master Boot Record (MBR)
13
Copyright ý . Systems – CSCI 402
MS-DOS Boot Program
One of the hard drive partitions is labeled as the active partition
The MS-DOS boot program finds the active partition
loads the first sector from it
which contains the “volume boot program”
pass control to that program
which then load the OS from that partition
14
321 0
Copyright ý . Systems – CSCI 402
Linux Booting (1)
Two stages of booting provided by one of:
lilo (Linux Loader)
uses sector numbers of kernel image
therefore, must be modified if a kernel image moves
grub (Grand Unified Boot Manager)
understands various file systems
can find a kernel image given a file system path name
both allow dual (or greater) booting select which system to boot from menu perhaps choice of Linux or Windows
The next step is for the kernel to configure itself
15
321 0
Copyright ý . Systems – CSCI 402
assembler code (startup_32)
assembler code (different startup_32)
Linux Booting (2)
Kernel image is compressed
step 1: set up stack, clear BSS, uncompress kernel, then transfer control to it
Process 0 is created
step 2: set up initial page tables,
turn on address translation (Ch 7) process 0 knows how to handle some aspects of paging
Do further initialization
step 3: initialize rest of kernel, create the “init” process (i.e., process 1, which is the ancestor of all other user processes) invoke the scheduler
C code (start_kernel)
Your kernel 1 assignment starts at step 3 above
NOTE: weenix is not exactly Linux Copyright ý . Cheng
321 0
16
Operating Systems – CSCI 402
BIOS Device Drivers
Originally, the BIO provided drivers for all devices
OS would call BIOS-provided code whenever it required services of a device driver
These drivers sat in low memory and provided minimal functionality
later systems would copy them into primary memory even later systems would provide their own drivers nevertheless, BIO drivers are still used for booting
how else can you do it?
17
321 0
Copyright ý . Cheng
designed for 16-bit x86 of mid 1980s
not readily extensible to other architectures
Open Firmware
designed by Sun
portable
drivers, boot code in Forth
compiled into bytecode
Intel developed a replacement for BIOS called EFI (Extensible Firmware Interface)
also uses bytecode
Operating Systems – CSCI 402
BIOS
Beyond BIOS
18
321 0
Copyright ý . Systems – CSCI 402
Ch 4: Operating-System Design
http://merlot.usc.edu/william/usc/
19
321 0
Copyright ý . Systems – CSCI 402
OS Design
We will now look at how OSes are constructed
what goes into an OS
how they interact with each other
how is the software structured
how performance concerns are factoered in
We will introduce new components in this chapter
scheduling (Ch 5)
file systems (Ch 6) virtual memory (Ch 7)
We will start with a simple hardware configuration
what OS is needed to support this
Applications views the OS as the “computer”
the OS needs to provide a consistent and usable interface while being secure and efficient
that¡¯s a pretty tall order!
321 0
20
Copyright ý . Systems – CSCI 402
OS Design
Our goal is to build a general-purpose OS can run a variety of applications
some are interactive
many use network communication all read/write to a file system
it¡¯s like most general-purpose OSes
Linux Solaris
FreeBSD Mac OS X
Chromium OS (has a Linux kernel)
Windows (the only one that¡¯s not directly based on Unix)
all these OSes are quite similar, functionally! they all provide:
processes threads
file systems network protocols with similar APIs user interface with display, mouse, keyboard
access control based on file ownership and that file owers can control
321 0
21
Copyright ý . Cheng
efficiency of application
Modularity
tradeoffs between modularity and performance
Device independence
for new devices, don¡¯t need to write a new OS
Security/Isolation
isolate OS from application
Operating Systems – CSCI 402
Performance
OS Design Issues
22
321 0
Copyright ý . Configuration
Operating Systems – CSCI 402
Processor
Network Interface
Primary Storage
Disk
Terminal with Display, Keyboard
Early 1980s OS, so we can focus on the basic OS issues
no support for bit-mapped displays and mice
generally less efficient design Copyright ý . Cheng
321 0
23
Operating Systems – CSCI 402
OS Components
App
App
Applications OS
Processor Management
Memory Management
I/O Management
24
321 0
Copyright ý . Cheng