Linux System Architecture
Linux System Architecture
Architecture-Dependent Code
Hardware
Architectural Approaches
• Monolithic.
• Layered.
• Modularized.
• Micro-kernel.
• Virtual machine.
Summary
• Linux is a modular, UNIX-like monolithic kernel.
• Kernel is the heart of the OS that executes with
special hardware permission (kernel mode).
• “Core kernel” provides framework, data
structures, support for drivers, modules,
subsystems.
• Architecture dependent source sub-trees live
in /arch.
Booting and Kernel
Initialization
System Lifecycle: Ups & Downs
Power Power
on off
Boot Kernel OS RUN! Shut
Init Init down
Boot Terminology
• Loader:
– Program that moves bits from disk (usually)
to memory and then transfers CPU control to the newly
“loaded” bits (executable).
• Bootloader / Bootstrap:
– Program that loads the “first program” (the kernel).
• Boot Manager:
– Program that lets you choose the “first program” to load.
LILO: LInux LOader
• A versatile boot manager that supports:
– Choice of Linux kernels.
– Boot time kernel parameters.
– Booting non-Linux kernels.
– A variety of configurations.
• Characteristics:
– Lives in MBR or partition boot sector.
– Has no knowledge of filesystem structure so…
– Builds a sector “map file” (block map) to find kernel.
• /sbin/lilo – “map installer”.
– /etc/lilo.conf is lilo configuration file.
/sbin/init
• Ancestor of all processes (except idle/swapper
process).
• Controls transitions between “runlevels”:
– 0: shutdown
– 1: single-user
– 2: multi-user (no NFS)
– 3: full multi-user
– 5: X11
– 6: reboot
• Executes startup/shutdown scripts for each runlevel.
Advanced Boot Concepts
• Initial ramdisk (initrd) – two-stage boot for flexibility:
– First mount “initial” ramdisk as root.
– Execute linuxrc to perform additional setup, configuration.
– Finally mount “real” root and continue.
– See Documentation/initrd.txt for details.
– Also see “man initrd”.
• Net booting:
– Remote root (Diskless-root-HOWTO).
– Diskless boot (Diskless-HOWTO).
Summary
• Bootstrapping a system is a complex, device-dependent process that
involves transition from hardware, to firmware, to software.
• Booting within the constraints of the Intel architecture is especially
complex and usually involves firmware support (BIOS) and a boot manager
(LILO).
• /sbin/lilo is a “map installer” that reads configuration information and
writes a boot sector and block map files used during boot.
• start_kernel is Linux “main” and sets up process context before spawning
process 0 (idle) and process 1 (init).
• The init() function performs high-level initialization before exec’ing the
user-level init process.
System Calls
System Calls
• Interface between user-level processes and
hardware devices.
– CPU, memory, disks etc.
• Make programming easier:
– Let kernel take care of hardware-specific issues.
• Increase system security:
– Let kernel check requested service via syscall.
• Provide portability:
– Maintain interface but change functional
implementation.