Introduction to Operating Systems
Press Next → or use ← → arrow keys
What Is an Operating System?
An operating system is that control tower for your computer. Programs constantly demand the CPU, memory, disk and network. The OS sits between them and the hardware, granting access fairly, safely and efficiently.
An operating system is the software layer that acts as an intermediary between the user and the hardware — making programs convenient to run while managing every resource behind the scenes.
Three Ways to See the Same OS
The Four-Layer Computer Architecture
Every request travels down the stack toward the hardware and every result travels back up to the user. The OS kernel is the gatekeeper in the middle.
Applications never touch hardware directly. They ask the kernel, which checks permissions and translates the request into safe hardware operations. This indirection is exactly what keeps one crashing app from taking down the whole machine.
Four Ways to Build a Kernel
| Structure | Idea | Trade-off | Examples |
|---|---|---|---|
| Monolithic | All services in kernel space | Fast · fragile | MS-DOS, early Linux |
| Layered | Strict layer hierarchy | Clean · slower | THE, early Multics |
| Microkernel | Minimal core, servers outside | Robust · messaging cost | QNX, MINIX, Mach |
| Modular / Hybrid | Monolithic core + loadable modules | Best of both ✅ | Linux, Windows NT, macOS |
Today's mainstream OSes are hybrid: a fast monolithic-style core with the extensibility of loadable modules. Linux loads drivers on demand; Windows NT and macOS blend a microkernel heritage with kernel-mode modules for speed.
Dual-Mode Operation — The Mode Bit
A single mode bit in the CPU decides what code is allowed to do. In user mode a program cannot touch hardware directly — it must knock on the door with a system call, which flips the CPU into kernel mode just long enough to serve the request. A buggy app literally cannot execute privileged instructions.
Multiprogramming · Multitasking · Time-Sharing
All three keep the CPU busy by switching between jobs — they differ only in when the switch happens.
Like a flip-book that turns still frames into motion, rapid context switching turns a single CPU into what feels like many. Nothing is truly simultaneous on one core — it is just switched faster than you can perceive.
Interrupts vs Traps — How the OS Wakes Up
| Feature | Interrupt | Trap (Exception) |
|---|---|---|
| Trigger | Hardware event | Software event |
| Timing | Asynchronous — any time | Synchronous — exact instruction |
| Source | Device: keyboard, disk, timer | User code: syscall, divide-by-zero |
| Response | Interrupt Service Routine runs | Trap handler runs |
System Calls — The Only Legal Door
A system call is the single, guarded entry point from user space into the kernel. Every file you open, every byte you send over the network, goes through one.
strace
Run strace ls and watch a simple directory listing fire off
~140 system calls — openat, getdents64,
write, close. Every interaction with the outside world is a
documented trip through the kernel door.
The Six Core Components
Around the kernel sit six specialists: Process, Memory, File System, Secondary Storage, I/O, and Protection & Security. Together they mirror every physical resource — and every risk of sharing it.
What Each Component Actually Does
| Component | Responsibility | Key Techniques |
|---|---|---|
| 🔄 Process Management | Create, schedule & terminate processes | Scheduling, IPC, deadlock handling |
| 🧠 Memory Management | Allocate & reclaim RAM | Paging, segmentation, virtual memory |
| 🗂️ File-System Mgmt | Abstract disk blocks as files/folders | Directories, permissions, metadata |
| 💽 Secondary Storage | Manage the disk beneath the files | Disk scheduling, free-space tracking |
| 🔌 I/O System | Talk to every device uniformly | Buffering, caching, spooling, drivers |
| 🛡️ Protection & Security | Keep users/processes isolated | Access control, authentication, audit |
These are not abstractions — you can watch them: top shows process
scheduling, free shows memory management, df/ls -l
show the file system, and lsof shows open I/O handles.
The Life of a Process — Five States
A process is admitted (NEW → READY), dispatched to the CPU (READY → RUNNING), and may pause for I/O (RUNNING → WAITING) before returning to the queue (WAITING → READY). When its work is done it exits (RUNNING → END). The scheduler drives every transition.
Virtual Memory — The Grand Illusion
Each program gets its own private, contiguous virtual address space. The MMU and page table quietly map those virtual pages to scattered physical frames. When a page is not in RAM, a page fault fetches it from disk — letting you run programs larger than physical memory.
Files, Permissions & Security
-rw-r--r--- → file type. A dash is a regular file; d is a directory, l a symbolic link.
rw- → owner can read and write, but not execute.
r-- → group can only read.
r-- → everyone else can only read.
| Security Concept | Question It Answers | Example |
|---|---|---|
| Authentication | Who are you? | Password, fingerprint, key |
| Authorization | What may you do? | Read-only vs read-write access |
| Audit | What happened? | Login & access logs |
| Isolation | Are you contained? | Separate process memory spaces |
The Major Types of Operating Systems
| Type | Defining Trait | Examples | Where You'll Find It |
|---|---|---|---|
| 🗃️ Batch | Jobs queued, no interaction | IBM OS/360 | Payroll, billing runs |
| 👥 Time-Sharing | Many users at once | UNIX | Shared servers |
| 🌐 Distributed | Coordinates many machines | Amoeba, Plan 9 | Data centres |
| ⏰ Real-Time | Hard deadlines guaranteed | QNX, VxWorks | Avionics, robotics |
| 📟 Embedded | Tiny footprint, one job | Contiki, FreeRTOS | Smart devices, sensors |
| 📱 Mobile | Touch UI, power-efficient | Android, iOS | Phones, tablets |
The same core job — manage resources, protect the system, present an interface — is tuned very differently for a data centre versus a pacemaker versus a phone. The constraints (deadlines, power, scale) decide the design.
One Command, All Six Components — ls
ls and press Enter. The keyboard raises a hardware interrupt; the I/O system reads it via the driver.fork(). Process management creates a new child process to run the command.execve(). Memory management maps the ls program into a fresh virtual address space.getdents() asks the file system for directory entries, which the storage layer fetches from disk.write() sends the names to your terminal via the I/O system; _exit() lets process management reclaim the resources. Protection checked permissions the whole way.A command that feels instant quietly engages all six components and dozens of system calls. That orchestration — invisible and reliable — is the operating system doing its job.
Seven Ideas Worth Remembering
strace, top, free,
and lsof let you watch the theory run live.
The Foundation Beneath Every Program
Everything ahead — process scheduling, memory allocation algorithms, file systems, concurrency, and security — builds on what you just learned. The structure, the dual-mode protection, and the six components are the vocabulary of the entire subject.
Dive into CPU scheduling and process synchronization, then
memory management and deadlocks. Experiment on any Linux shell with
strace, top, and ps to see each concept in action.
🖥️ End of tutorial · Press ← to review, or click Restart