Operating Systems 📂 Introduction · 1 of 5 48 min read

Introduction to Operating Systems — Structure, Operations & Core Components

A complete Galvin-style deep dive into operating systems — what an OS is, its three views, the four-layer architecture, every kernel structure (monolithic, layered, microkernel, modular, hybrid), OS operations (dual-mode, multiprogramming, multitasking, interrupts, traps, system calls), and all six core components. Includes live animated SVG diagrams, comparison tables, and hands-on Linux examples with strace, ps, and free.

Section 01

What Is an Operating System?

The Airport Traffic Controller
Imagine a busy airport. Hundreds of planes want to land, take off, refuel, and taxi — all at once. Without a control tower coordinating everything, planes would crash, runways would jam, and chaos would follow.

Your computer is that airport. The CPU, RAM, disk, keyboard, printer are runways and gates. Programs (browser, editor, games) are the planes. The Operating System is the control tower — deciding who runs when, who gets memory, who talks to the printer, and who must wait.

That is the entire job of an OS: orchestrating shared hardware among competing programs, safely and fairly.

Formally (Galvin): an Operating System is a program that acts as an intermediary between a user of a computer and the computer hardware. Its purpose is to provide an environment in which a user can execute programs in a convenient and efficient manner.

The Three Views of an Operating System

One OS · Three Different Lenses
OPERATING SYSTEM USER VIEW Friendly & usable SYSTEM VIEW Resource allocator GOAL VIEW Control program
💻
The Three Views Explained

User view — a friendly interface that makes the machine usable. System view — a resource allocator that manages CPU, memory, I/O. Goal view — a control program that prevents errors and improper use. All three describe the same OS from different angles.


Section 02

Where the OS Sits — The Four-Layer View

A computer system can be divided into four layers. The OS sits squarely in the middle, shielding users and applications from the raw complexity of hardware.

Animated Architecture — The Four Layers in Motion

System Architecture · Data Flows Through Every Layer
LAYER 4 USER (Humans) You · developers · admins · everyday users LAYER 3 APPLICATION PROGRAMS Browser · Compiler · Word · Games · IDE LAYER 2 OPERATING SYSTEM (Kernel) Scheduler · Memory Mgr · File System · I/O · Protection LAYER 1 HARDWARE CPU · RAM · Disk · Keyboard · Monitor · NIC request↓ ↑ response Every request from user → app → OS → hardware and every response comes back the same path
🔑
Why the Layer Matters

Because the OS sits between apps and hardware, you can run the same Chrome binary on machines with different CPUs and disks. The OS hides those differences behind uniform system calls like read(), write(), fork(). Change the hardware — the OS adapts; apps never notice.


Section 03

OS Structure — How the Kernel Is Organised

Not every OS is built the same way internally. Galvin lists four dominant structural designs, each representing a different trade-off between simplicity, performance, and reliability.

Animated Comparison — Four Kernel Structures

Monolithic · Layered · Microkernel · Modular
MONOLITHIC Scheduler Memory Mgr File System Drivers IPC · Network All in ONE space MS-DOS, early Linux LAYERED Layer N (UI) Layer N-1 Layer 1 (drivers) Layer 0 (HW) THE / early Multics MICROKERNEL Micro kernel FS Net Driver Mem QNX, MINIX, Mach MODULAR / HYBRID Core Kernel Sched · Mem · IPC wifi.ko nvidia ext4.ko usb.ko audio Linux, Windows NT, macOS Fast · Fragile Clean · Slow Reliable · IPC cost Modern winner Each design trades safety, speed, and maintainability differently Modern OSes are hybrids — monolithic core + loadable modules Watch: layered packet cascading, microkernel servers orbiting, modules pulsing in/out
🏗️
Monolithic
One giant kernel
All OS services (scheduler, memory, file system, drivers) run in one huge kernel address space. Fast, but a single bug can crash the whole system. + Very fast (no message passing) - Hard to maintain, less reliable
📦
Layered
Stacked layers
OS is broken into strict layers; each layer only uses services of the layer below. Easier to debug but slower due to indirection. + Clean abstraction, easy to debug - Layer traversal adds overhead
🔌
Microkernel
Minimal core
Kernel keeps only essentials (IPC, basic scheduling). Drivers and file systems run as user-space servers. Highly reliable — used in QNX, MINIX, macOS Mach. + Extensible, isolates faults - IPC overhead slows performance
🧩 Modular / Hybrid — The Modern Winner
Idea
Start with a monolithic core but allow parts (drivers, file systems) to be loaded and unloaded at runtime as kernel modules.
Used By
Linux (LKM — loadable kernel modules), Windows NT/10/11, macOS (XNU = Mach microkernel + BSD monolithic).
Command
On Linux, list loaded modules with lsmod. Load a new one with sudo modprobe <name>. Unload with sudo rmmod <name>.
# Linux — see all loaded kernel modules right now
$ lsmod | head -10
Module                  Size  Used by
nvidia_drm             77824  4
nvidia_modeset       1339392  6 nvidia_drm
nvidia              62492672  308 nvidia_modeset
snd_hda_intel          61440  2
btusb                  73728  0
bluetooth            1257472  49 btusb
uvcvideo              139264  0
xhci_pci               24576  0
ext4                  962560  1

# Get info about one module
$ modinfo ext4 | head
filename: /lib/modules/6.5.0/kernel/fs/ext4/ext4.ko
license:  GPL
description: Fourth Extended Filesystem

Section 04

OS Operations — What the OS Does at Runtime

Modern operating systems perform four fundamental operational patterns. Understanding these is understanding why multitasking, security, and interrupts exist.

4.1 Dual-Mode Operation — The Hardware-Enforced Boundary

The Mode Bit Switches Continuously
USER MODE (bit = 1) KERNEL MODE (bit = 0) Your Chrome tab Your Python script Can't touch hardware · Can't run privileged instructions Must ask kernel via a system call Scheduler Memory Mgr Drivers File System Full hardware access · All memory · Privileged instructions MODE BIT USER KERNEL Packet turns amber crossing the boundary — a hardware-enforced mode switch
🔒
Why Dual Mode Matters

Without dual mode, a buggy user program could overwrite kernel memory, halt the CPU, or read another user's data. The hardware-enforced mode bit is what turns a computer from a toy into a multi-user, multi-tasking machine.

4.2 Multiprogramming, Multitasking & Timesharing

Three Progressive Ideas — Same Goal, Different Scale
MULTIPROGRAMMING MULTITASKING TIME-SHARING Job A Job B (A blocked on I/O) Job C Switch trigger: I/O wait (rare, seconds apart) P1 P2 P3 P1 P2 Switch trigger: timer / interaction (100s of ms) Switch trigger: tiny timer quantum (10 ms) → illusion of a private CPU Each row shows the same CPU across time — switches get finer as we go down

4.3 Interrupts & Traps — The Heartbeat of an OS

The Interrupt Life Cycle
User process runs ⚡ Device IRQ Save state → kernel mode → ISR Look up interrupt vector table entry Restore state → user resumes 1. Program running normally 2. Device raises IRQ 3. Kernel handles it (ISR) 4. User resumes seamlessly Interrupt = hardware event (keyboard, disk, timer, network) Trap = software event (system call, divide-by-zero, page fault)
⚡ Interrupt (Hardware)
Asynchronous — arrives any time
Raised by external device (disk done, packet arrived, timer)
User process is preempted involuntarily
Kernel runs the matching ISR
💾 Trap (Software)
Synchronous — happens on a specific instruction
Caused by user code (syscall, divide by 0, invalid access)
User process explicitly asks the kernel
Kernel runs the matching handler

4.4 System Calls — The Only Legal Door

# Linux — trace every system call a program makes
$ strace -c ls

# Kernel entries per syscall type
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 24.11    0.000123           7        17           mmap
 18.63    0.000095           5        18           openat
 12.55    0.000064           3        18           close
 11.37    0.000058           3        16           read
  9.02    0.000046           2        18           fstat
------ ----------- ----------- --------- --------- ----------------
100.00    0.000510                    140         0 total
TAKEAWAY
Even a simple `ls` quietly enters the kernel 140 times via system calls. Every "boring" command is a small conversation with the OS.

Section 05

The Six Core Components of an Operating System

Galvin organises OS functionality into six major management subsystems. Every task the OS performs falls under one of these six.

Animated Overview — Six Managers Serving One Kernel

The Six Core Components in Action
OS Kernel Process Mgmt Memory Mgmt File System Storage Mgmt I/O System Protect & Security Every OS request routes through one of these six managers
01
Process Management
Creates, schedules, suspends, and terminates processes. Handles synchronisation, deadlock, and inter-process communication. Linux: ps, top, kill.
02
Main Memory Management
Tracks which parts of RAM are in use and by whom. Allocates and reclaims memory, implements paging and virtual memory. Command: free -h.
03
File-System Management
Provides files and directories as an abstraction over disk blocks. Handles permissions, access, backup. Examples: ext4, NTFS, APFS. Command: df -h.
04
Secondary-Storage Management
Manages disks below the file-system level: free-space tracking, allocation, disk scheduling (SSTF, SCAN, C-SCAN). Command: lsblk, iostat.
05
I/O System Management
Buffers, caches, and spools data to and from devices. Provides a uniform driver interface so apps don't care whether they're writing to a printer or a USB stick.
06
Protection & Security
Enforces access control between processes and users. Handles authentication (login), authorisation (permissions), defence against malware. Command: chmod, sudo.

Section 06

Component Deep-Dive with Examples

6.1 Process Management in Action

# Running processes with PID, CPU%, MEM%, state
$ ps -eo pid,user,%cpu,%mem,state,comm --sort=-%cpu | head -6

  PID USER      %CPU %MEM S COMMAND
 2841 mohit     34.2  8.1 R chrome
 1923 mohit     12.7  4.5 S code
 1105 root       3.4  1.2 S systemd
 2201 mohit      2.1  0.9 S gnome-shell
  845 root       0.8  0.3 S sshd

# State column: R=Running, S=Sleeping, D=Uninterruptible, Z=Zombie

Animated Process States — The Five-State Model

A Process's Life Cycle
NEW being created READY waiting for CPU RUNNING on CPU now WAITING blocked on I/O TERMINATED exit() admit dispatch timer I/O wait I/O done exit Watch the pulse move through a process's lifetime — thousands per second in real systems

6.2 Memory Management — The Virtual Memory Illusion

Virtual → Physical Address Translation
PROCESS A Virtual addresses 0x0040_1000 0x0040_2000 0x0040_3000 MMU + Page Table Hardware translation Page 401 → Frame #12 Page 402 → Frame #48 Page 403 → SWAP ↑ Page fault triggers load from disk PHYSICAL RAM Real bytes 0x00C_0000 (F#12) 0x0300_0000 (F#48) swap/disk Every process thinks it owns the entire address space The OS + MMU maintain the illusion by remapping on every access If a page is on disk → page fault → OS loads it → resumes the process
# Inspect real memory usage
$ free -h
              total    used    free   shared  buff/cache   available
Mem:          15Gi   6.2Gi   2.1Gi    412Mi       7.3Gi        8.4Gi
Swap:        4.0Gi   128Mi   3.9Gi

6.3 File System — Everything Is a File (UNIX Philosophy)

# List files with permission bits, owner, size
$ ls -l /etc/passwd
-rw-r--r-- 1 root root 3021 Jul 18 09:14 /etc/passwd

# Decode the 10 permission characters:
#  -   rw-  r--  r--
#  │    │    │    └─ Others: read only
#  │    │    └────── Group:  read only
#  │    └─────────── Owner:  read + write
#  └──────────────── Type:   - regular, d dir, l link, c char, b block

6.4 Protection & Security — Users, Groups, Privileges

ConceptPurposeLinux Example
AuthenticationVerify who you arelogin, PAM, /etc/shadow
AuthorisationControl what you can doFile permissions, sudo, capabilities
AuditRecord what happened/var/log/auth.log, journalctl
IsolationSeparate processes / usersAddress spaces, namespaces, containers

Section 07

Types of Operating Systems — Quick Comparison

TypePurposeExampleUse Case
Batch OSRuns job queues without user interactionIBM OS/360Payroll, billing
Time-SharingMany users on one machineUNIX, MulticsServers, mainframes
Distributed OSCoordinates many networked computersAmoeba, Plan 9Data centres, clusters
Real-Time OSHard deadline guaranteesVxWorks, QNX, FreeRTOSAvionics, ABS brakes, robotics
Embedded OSTiny footprint, dedicated deviceContiki, TinyOSSmart bulbs, sensors
Mobile OSTouch UI, power efficiencyAndroid, iOSPhones, tablets

Section 08

Practical — What Happens When You Type ls

🔍 From Keystroke to Output — A Full OS Journey
Step 1
You press l, s, Enter. The keyboard controller raises an interrupt. CPU jumps into kernel mode.
Step 2
Kernel's keyboard driver reads scan codes, converts to ASCII, delivers them to the shell process.
Step 3
Shell (bash) parses the command, calls fork() — a system call — to create a child process.
Step 4
Child calls execve("/bin/ls"). Kernel loads the ls binary from disk via the file system, sets up its memory pages.
Step 5
ls issues getdents() to read directory entries — kernel talks to the disk driver.
Step 6
ls formats the output and calls write(1, buf, len). Kernel forwards bytes to the terminal driver, which paints the pixels.
Step 7
ls calls _exit(0). Kernel reclaims memory, notifies the parent shell via SIGCHLD, and the prompt returns.
🏆
All Six Components Played a Role

Process (fork/exec), Memory (loading pages), File system (finding /bin/ls), Storage (block reads), I/O (keyboard + terminal), Protection (checking your UID against directory permissions). One command exercises the entire OS.


Section 09

Golden Rules — Foundations to Remember

📚 OS Fundamentals — Non-Negotiable Takeaways
1
An OS is a resource manager + control program + user interface — all three simultaneously. Even the "empty" desktop has millions of kernel instructions running per second.
2
Dual-mode operation (user vs kernel) is what makes modern computing safe. Hardware — not software — enforces it via the mode bit.
3
Applications reach the kernel only through system calls. Every meaningful action (open a file, allocate memory, send a packet) is ultimately a syscall.
4
Interrupts are the OS's heartbeat. Without them the CPU could never react to devices or preempt runaway processes. Timer interrupts drive the scheduler itself.
5
The six components — Process, Memory, File, Storage, I/O, Protection — are not arbitrary; they mirror the physical resources of any computer and the risks of sharing them.
6
Modern OS structure is hybrid — pure monolithic and pure microkernel designs both compromise too much. Linux, Windows, and macOS all sit somewhere in between with loadable modules.
7
Learning the OS means learning to see it. Use strace, top, free, lsof, dmesg. Every one of these is a window into a subsystem Galvin describes.