STUDY GUIDE · 3 INTERACTIVE LABS · ABOUT 12 MIN

Your computer runs hundreds of programs on a handful of cores.

The operating system is the referee that makes it look effortless. It decides which program runs next, hands out memory, and stops programs from trampling each other. This guide lets you be the referee.

The core of the OS: the scheduler, memory manager, file system and network stack, all running with full access.

What is an operating system?

An operating system (OS) is the software that manages a computer's hardware and gives programs a safe, shared way to use it. Its core, the kernel, schedules the CPU, manages memory, runs the file system and talks to devices through drivers.

Programs never touch hardware directly. They ask the kernel through system calls, and the CPU enforces the boundary: user code runs in a restricted mode, the kernel in a privileged one. Windows, macOS, Linux, Android and iOS all follow this design.

Process schedulingShares the CPU between programs, switching many times a second.
Memory managementGives each program its own private address space.
File systemsTurns raw disk blocks into files and folders.
ProtectionKeeps programs from reading or breaking each other.
LAB 1 · CPU SCHEDULING

Four processes, one CPU. Who goes first?

Each process arrives at a set time and needs a certain amount of CPU time. Pick a scheduling algorithm and change the burst times to see who waits, and for how long.

P1arrives t=0burst 6waited 0
P2arrives t=1burst 3waited 5
P3arrives t=2burst 8waited 7
P4arrives t=3burst 2waited 14
GANTT CHART
P1P2P3P4
06917
19
6.50avg waiting time
11.25avg turnaround
First come, first served is simple and fair in order, but a long job at the front makes everyone behind it wait: the convoy effect. SJF would average 4.75.
LAB 2 · VIRTUAL MEMORY

When memory is full, which page goes?

A program asks for pages of memory in the order along the top. Only a few fit in RAM (the frames). A request for a page that isn't loaded is a page fault, which means a slow trip to disk. Different eviction rules cause different numbers of faults.

Frames:
7
7
fault
0
70
fault
1
701
fault
2
201
fault
0
201
hit
3
203
fault
0
203
hit
4
403
fault
2
402
fault
3
432
fault
0
032
fault
3
032
hit
2
032
hit
10FIFO faults
9LRU faults
7Optimal faults
LRU evicts the page used least recently, betting that the recent past predicts the near future. Real systems approximate it because exact tracking is costly.

Core ideas at a glance

ProcessA running program with its own memory, registers and open files.
ThreadA path of execution inside a process; threads share the process's memory.
Context switchSaving one process's state and loading another's: the cost of multitasking.
Virtual memoryEach process sees its own address space, mapped to RAM pages by the OS and hardware.
Page faultA request for a page not in RAM, so the OS loads it from disk.
DeadlockProcesses each waiting for resources the others hold; none can continue.
Mutex / semaphoreLocks that stop threads from corrupting shared data.
Kernel vs user modeHardware-enforced privilege levels that protect the system.

From batch jobs to phones

1956Batch systems.GM-NAA I/O ran jobs one after another on IBM mainframes.
1961Time-sharing.MIT's CTSS let many users share one computer interactively.
1969Unix.Ken Thompson and Dennis Ritchie at Bell Labs; rewritten in C in 1973.
1985Windows 1.0.Microsoft's graphical shell on top of MS-DOS.
1991Linux.Linus Torvalds released a free Unix-like kernel; it now runs most servers and Android.
2007iPhone OS.Mobile operating systems put a Unix-family kernel in billions of pockets.

Further reading

Operating System ConceptsSilberschatz, Galvin & Gagne · the classic 'dinosaur book'
Operating Systems: Three Easy PiecesRemzi & Andrea Arpaci-Dusseau · free online
Modern Operating SystemsAndrew S. Tanenbaum · by the creator of MINIX
Test yourself: 20 OS questionsComputer science guide

Your brain schedules tasks too. How well?

Our full IQ test measures working memory, processing speed and reasoning: 60 questions, about 30 minutes.

Take the full IQ test