Genesis: From raw hardware to process

Download Report

Transcript Genesis: From raw hardware to process

Genesis: from raw hardware to
processes
System booting sequence: how
does a machine come into life
How is the First Process
Created?


What happens when you turn on a
computer?
How to get from raw hardware to the
first running process, or process 1
under UNIX?
Booting Sequence


The address of the first instruction is
fixed
It is stored in read-only-memory (ROM)

ROM is read-only, permanent memory, and
is always available to be used.
Booting Procedure for i386
Machines

On i386 machines, ROM stores a Basic
Input/Output System (BIOS)

BIOS contains program that knows how to
access storage devices, keyboard, and
graphic card.
BIOS Code

Performs Power-On Self Test (POST)


Tests the system
Looks for and checks peripherals


During this time, you will hear memory
counting, which consists of noises from the
floppy and hard drive, followed by a final beep
Locates a valid device with which to boot
the system (boot device)

Floppy  CDROM  hard drives
After the POST


The master boot record (MBR) is loaded
by BIOS from the boot device.
The MBR is stored at the first logical sector
(track 0, cylinder 0, and head 0) of the boot
device (e.g., a hard drive) that

Fits into a single 512-byte disk sector (boot
sector)


Boot loader: machine code instructions for booting the
machine.
Partition table: the physical layout of the disk (e.g.,
number of tracks)
After Getting the Info on the
Boot Device


BIOS loads a more sophisticated loader
from the boot sector and yields control
to it.
Under Linux, this sophisticated loader is
called LILO (Linux Loader) or Grub
(GNU Grub Unified Boot Loader).

The more sophisticated loader loads the
operating system
More on OS Loaders

LILO

Is partly stored in MBR with the disk partition table.


A small machine code binary on the MBR whose job is to
locate the second stage boot loader and load the first part of
it into memory.
A user can specify which disk partition and OS image to boot



Every time a configuration change is made, run ‘/sbin/lilo’ to
change MBR.
Windows loader assumes only one bootable disk partition
After loading the kernel image, LILO sets the kernel
mode and jumps to the entry point of the operating
system
Booting Sequence in Brief








A CPU jumps to a fixed address in ROM,
Loads the BIOS,
Performs POST,
Loads MBR from the boot device,
Loads an OS loader,
Loads the kernel image,
Sets the kernel mode, and
Jumps to the OS entry point.
Linux Initialization

Set up a number of things:








Trap table
Interrupt handlers
Scheduler
Clock
Kernel modules
…
Process manager
Hand-craft environment for the init process (the
first process, process 1).
Process 1




Is instantiated from the init program
Is the ancestor of all processes
Controls transitions between runlevels
Executes startup and shutdown scripts
for each runlevel

On RedHat, the init do the following (run as a
process)





Run /etc/rc.d/rc.sysinit that sets environment
path, checks file system, etc (system initialization)
Run /etc/inittab script that decides how system
should be setup in each runlevel.
Set the source function library, /etc/rc.d/init.d,
how to start and kill a program, etc
Start all background processes by looking at the rc
directories for the runlevel as default in
/etc/inittab: e.g /etc/rc.d/rc5.d for runlevel 5.
Fork /sbin/mingetty to give virtual consoles (login
prompts).
Runlevels






Level 0: shutdown
Level 1: single-user
Level 2: multi-user (without network
file system)
Level 3: full multi-user
Level 5: X11
Level 6: reboot