OS Intro
An operating system (OS) is the layer of software that sits between your programs and the hardware. When a text editor saves a file, a browser opens a network connection or a game asks for more memory, none of them talks to the disk, the network card or the RAM chips directly. They ask the operating system, and the OS does the work on their behalf, safely and fairly.
This course explains how that works inside, using the two operating systems you are most likely to meet: Linux (servers, phones through Android, containers, the cloud) and Windows (desktops, laptops, many company servers). macOS shares most of its ideas with Linux because both descend from Unix.
The three jobs of an operating system
| Job | What it means | Linux example | Windows example |
|---|---|---|---|
| Abstraction | Hide messy hardware behind simple ideas: files, processes, sockets | everything is a file descriptor | everything is a handle to a kernel object |
| Resource management | Share CPU time, memory, disk and network between many programs | CFS/EEVDF scheduler, page cache | thread scheduler with priorities, memory manager |
| Protection | Stop one program (or user) from damaging another | users, permissions, namespaces | user accounts, access tokens, ACLs, UAC |
A useful way to remember it: the OS is both a magician (it makes one CPU look like many, and a small amount of RAM look like a huge private memory for each program) and a referee (it decides who gets what and enforces the rules).
+-----------+ +-----------+ +-----------+
| browser | | editor | | shell | applications (user mode)
+-----+-----+ +-----+-----+ +-----+-----+
| | |
======|==============|==============|======= system call boundary
v v v
+-------------------------------------------+
| operating system kernel | scheduler, memory, files,
| | network, drivers
+---------------------+---------------------+
|
+---------------------v---------------------+
| hardware: CPU, RAM, disk, NIC, GPU |
+-------------------------------------------+What counts as "the OS"?
Strictly speaking the operating system is the kernel: the privileged program that is always resident in memory and controls the hardware. In everyday speech "the OS" also includes everything that ships with it:
- Linux: the kernel is Linux itself. A distribution (Ubuntu, Fedora, Debian, Arch, Alpine) adds a C library (glibc or musl), an init system (usually systemd), a shell (bash), core tools (GNU coreutils) and a package manager.
- Windows: the kernel is
ntoskrnl.exe(the NT kernel and executive) plus the hardware abstraction layer and drivers. Around it Microsoft ships the Win32 subsystem, the Explorer shell, services, the registry and much more, all as one product.
You can ask a Linux system what kernel it runs. The kernel name is always Linux; the version and machine type
differ from computer to computer, so the example only prints the stable part:
echo "kernel name: $(uname -s)"
echo "page size: $(getconf PAGESIZE) bytes"
head -1 /proc/self/statuskernel name: Linux
page size: 4096 bytes
Name: head
/proc/self/status is not a real file on disk: it is generated by the kernel on the fly and describes the process
that reads it (here, head). You will meet /proc again in /proc & /sys.
On Windows the same questions are answered by ver, systeminfo or PowerShell (sample output, yours will differ):
C:\Users\ada>ver
Microsoft Windows [Version 10.0.26100.4652]PS C:\Users\ada> Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, OSArchitecture
Caption Version OSArchitecture
------- ------- --------------
Microsoft Windows 11 Pro 10.0.26100 64-bitWindows 11 still reports itself as version 10.0 internally; the build number (26100 here) is what really identifies the release.
Abstractions in action: a tiny "OS" in Python
The core trick of an OS is to give every program the illusion that it owns the machine. The toy below has one CPU and three programs. The "kernel" runs each for a short time slice, then switches to the next, so all three make progress even though only one runs at any moment:
programs = {
"editor": ["load file", "draw text", "save file"],
"browser": ["resolve name", "open socket", "render page", "play video"],
"backup": ["scan disk", "copy files"],
}
ready = list(programs) # the run queue
clock = 0
while ready:
name = ready.pop(0) # pick the next program
step = programs[name].pop(0)
clock += 1
print(f"t={clock:2} CPU runs {name:8} -> {step}")
if programs[name]:
ready.append(name) # not finished: back of the queue
else:
print(f" {name} exited")
print(f"{clock} time slices, 1 CPU, 3 programs that each thought they had it")t= 1 CPU runs editor -> load file
t= 2 CPU runs browser -> resolve name
t= 3 CPU runs backup -> scan disk
t= 4 CPU runs editor -> draw text
t= 5 CPU runs browser -> open socket
t= 6 CPU runs backup -> copy files
backup exited
t= 7 CPU runs editor -> save file
editor exited
t= 8 CPU runs browser -> render page
t= 9 CPU runs browser -> play video
browser exited
9 time slices, 1 CPU, 3 programs that each thought they had it
Real schedulers are far more clever (see CPU Scheduling), but the shape is the same: a queue of runnable tasks, a timer interrupt that takes the CPU back, and a context switch to the next task.
Linux and Windows at a glance
| Linux | Windows | |
|---|---|---|
| Kernel | Linux (monolithic, loadable modules) | NT (hybrid: kernel + executive + HAL) |
| Source | open source (GPLv2) | proprietary |
| Main API for programs | POSIX system calls via the C library | Win32 API (kernel32.dll, ntdll.dll) |
| Programs and libraries | ELF files, .so shared objects |
PE files, .exe and .dll |
| File systems | ext4, XFS, Btrfs | NTFS, ReFS, FAT32/exFAT |
| Paths | /home/ada/notes.txt (one tree) |
C:\Users\ada\notes.txt (drive letters) |
| Configuration | text files in /etc |
the registry + files |
| Services | systemd units | the Service Control Manager |
| Shells | bash, zsh | CMD, PowerShell |
How this course is organised
- OS basics: history, architecture, kernel designs, user vs kernel mode, system calls.
- Processes and threads: creation, scheduling, IPC, signals, synchronization and deadlocks.
- Memory: allocation, virtual memory and paging, page replacement, swap and the page file.
- File systems: concepts, ext4 and NTFS, the directory layouts, links and inodes.
- Linux internals and Windows internals: boot, systemd vs services,
/procvs the registry, security. - Comparison: Linux vs Windows, devices, networking, virtualization and containers.
Runnable Python simulations show the algorithms (schedulers, page replacement, allocators), real bash commands show Linux live, and Windows internals appear as realistic PowerShell and CMD sessions.
Tip: if you have never used a terminal, the Terminal & Command Line course is a gentle start. The Linux & Bash and PowerShell courses go deeper into scripting.
Learn more: Unix, Linux & Windows History · OS Architecture
Test yourself
Which part of the operating system runs with full hardware privileges and is always resident in memory?
- The shell
- The kernel
- The package manager
- The desktop environment
Making one CPU look like many by switching between programs quickly is an example of which OS job?
- Protection
- Abstraction / resource management
- Compilation
- Booting
What is the Windows equivalent of a Linux shared library (.so)?
.exe.dll.sys.msi