Chapter 2: Operating System Design and Implementation

Syllabus 9.2: Architecture, Kernel types, System Calls, Interrupts, Context Switching, Boot Process & Virtual Machines

Learning Objectives

After completing this chapter, you should be able to:

  • Explain OS architecture
  • Differentiate Monolithic Kernel and Microkernel
  • Understand System Calls
  • Explain Interrupts and Traps
  • Describe Context Switching
  • Explain the Boot Process
  • Understand Virtual Machines

1. Operating System Architecture

OS architecture refers to the internal structure and organization of an operating system. It defines how components interact, how services are provided, and how hardware resources are managed.

Basic Structure (Top to Bottom)
Users
↓ Application Programs
↓ Operating System
↓ Hardware

A modern OS contains: Kernel, Memory Manager, File Manager, Process Manager, Device Manager, Security Manager.


2. Kernel Architecture

The kernel is the most important component of the OS. It operates in two distinct modes:

Kernel Mode vs User Mode

ModeAccess LevelWho Runs Here
Kernel ModeFull hardware access, privileged instructions allowedOS kernel
User ModeRestricted accessApplications

Why Two Modes? If every application had direct access to RAM and CPU, it would cause system crashes, security issues, and data corruption. The separation ensures stability and security.

Flow
Applications (User Mode) ↓ System Call ↓ Kernel (Kernel Mode) ↓ Hardware

3. Monolithic Architecture

All OS services run inside one large kernel. Everything executes in kernel space.

AspectDetail
Services IncludedFile system, Device drivers, Memory manager, Process scheduler
StructureApplications ↓ Monolithic Kernel ↓ Hardware
Advantage: Fast PerformanceNo communication overhead between components
Advantage: EfficientDirect interaction among components
Disadvantage: Hard MaintenanceLarge, complex code base
Disadvantage: Low Fault IsolationOne faulty driver may crash the whole OS
ExamplesUNIX, Linux

4. Microkernel Architecture

Only essential services remain inside the kernel. Other services run in user space.

AspectDetail
Kernel ContainsScheduling, Memory management, IPC (Interprocess Communication)
StructureApplications ↓ User Services ↓ Microkernel ↓ Hardware
Advantage: Better SecuritySmaller kernel attack surface
Advantage: Better StabilityFault in one service will not crash the entire OS
Advantage: Easier MaintenanceModular design
DisadvantageSlower due to more communication required between components
ExamplesMINIX, QNX

Monolithic vs Microkernel

FeatureMonolithicMicrokernel
SizeLargeSmall
SpeedFasterSlower
SecurityLowerHigher
ReliabilityLowerHigher
MaintenanceDifficultEasier

📌 Exam Point: Which architecture provides better fault isolation? → Microkernel


5. Layered Architecture

The OS is divided into layers. Each layer uses only the services of the layer directly below it.

LayerComponent
Layer 5User Programs
Layer 4File System
Layer 3Process Management
Layer 2Memory Management
Layer 1Hardware Interface
Layer 0Hardware
AdvantagesDisadvantages
Easy debuggingSlower due to layer overhead
Easy maintenanceStrict layer rules can be limiting
Better organization

6. Modular Architecture

Combines advantages of both Monolithic and Microkernel. Modules can be loaded and unloaded dynamically without rebooting.

Examples
Modern Linux kernels
Modern Windows kernels

7. Virtual Machine Architecture

One physical machine behaves like multiple independent computers.

Example: One computer running Windows, Linux, and Ubuntu simultaneously.

Structure
Guest OS | Guest OS | Guest OS
↓ Hypervisor
↓ Hardware

Hypervisor

Software that manages virtual machines.

TypeRuns OnExamples
Type 1 (Bare Metal)Directly on hardwareVMware ESXi, Microsoft Hyper-V
Type 2 (Hosted)On top of an existing OSOracle VM VirtualBox, VMware Workstation

8. System Calls

System calls are requests made by user programs to the OS kernel for services.

Why Needed? Applications cannot directly access hardware. They must ask the kernel for services via system calls.

Flow
Application ↓ System Call ↓ Kernel ↓ Hardware
CategoryExamples
File OperationsOpen file, Read file, Write file, Delete file
Process OperationsCreate process, Terminate process
Device OperationsRead keyboard, Write printer

📌 Exam Definition: System call is the interface between user programs and operating system services.


9. Interrupts

An interrupt is a signal that temporarily stops CPU execution and requests immediate attention.

Example: While typing, the keyboard sends an interrupt. The CPU pauses its current task, handles the keyboard event, then resumes.

TypeGenerated ByExamples
Hardware InterruptPhysical devicesKeyboard, Mouse, Printer
Software InterruptProgramsSystem calls

Interrupt Handling Steps

StepAction
1Interrupt occurs
2CPU saves current state
3Interrupt Service Routine (ISR) executes
4CPU restores previous state
5Program continues

10. Trap

A trap is a software-generated interrupt, usually generated intentionally by a program or due to an error.

Examples of TrapsCause
Division by Zero (10 ÷ 0)Arithmetic error generates trap
System CallsAlso generate traps internally

Interrupt vs Trap

FeatureInterruptTrap
SourceExternal eventInternal event
Generated ByHardwareSoftware
ExampleKeyboard pressDivide by zero

11. Context Switching

One of the most important OS concepts.

Definition: Saving the state of one process and loading the state of another process so the CPU can switch between them.

Example: You are watching YouTube and typing notes. The CPU rapidly switches between both tasks.

What is Saved?Where?
Program CounterPCB (Process Control Block)
Registers
Process State
Context Switch Process
Process A Running ↓ Save State of A ↓ Load State of B ↓ Process B Running
Why Needed?
Multitasking
Time-sharing
Scheduling

⚠️ Important: Context switching creates overhead because the CPU performs no useful work during the switch itself.


12. Boot Process

Booting is the process of starting a computer and loading the OS into memory.

StepActionDetail
1Power OnComputer receives power
2BIOS / UEFI ExecutesRuns POST (Power-On Self-Test) — checks RAM, Keyboard, CPU, Storage
3Boot Loader LoadsLoads OS kernel — e.g. GRUB (Linux), Windows Boot Manager
4Kernel LoadsKernel enters memory
5System InitializationDrivers loaded, services started
6Login ScreenSystem ready for user

Cold Boot vs Warm Boot

FeatureCold BootWarm Boot
TriggerPower Off → OnRestart
InitializationFull initializationFaster
When UsedFirst startupReboot

Design Goals of an OS

GoalMeaning
1. ReliabilitySystem should not crash
2. EfficiencyMaximum hardware utilization
3. SecurityProtect resources from unauthorized access
4. ScalabilityHandle increasing workload
5. MaintainabilityEasy updates and bug fixes

Quick Revision Table

ConceptDefinition
KernelCore part of OS
System CallInterface between program and OS
InterruptSignal requesting CPU attention
TrapSoftware-generated interrupt
Context SwitchSwitching CPU between processes
BootingStarting a computer and loading OS
HypervisorSoftware managing virtual machines
PCBProcess Control Block — stores process state

Memory Tricks

MnemonicFull Form
OS Architectures — MMLV M → Monolithic
M → Microkernel
L → Layered
V → Virtual Machine
Boot Sequence — PBKSL P → Power On
B → BIOS / UEFI
K → Kernel Load
S → System Initialization
L → Login

Practice MCQs

  • 1. Which architecture keeps only essential services in the kernel?
    A. Monolithic   B. Layered   C. Microkernel   D. Modular
    ✅ Answer: C — Microkernel
  • 2. Which acts as an interface between applications and kernel?
    A. Driver   B. System Call   C. Scheduler   D. PCB
    ✅ Answer: B — System Call
  • 3. Which structure stores process information during context switching?
    A. RAM   B. File Table   C. PCB   D. Cache
    ✅ Answer: C — PCB (Process Control Block)
  • 4. Which occurs first during booting?
    A. Kernel Loading   B. Login Screen   C. POST   D. Driver Loading
    ✅ Answer: C — POST (Power-On Self-Test)
  • 5. Divide-by-zero error generates:
    A. Hardware Interrupt   B. DMA   C. Trap   D. Scheduler
    ✅ Answer: C — Trap