What Is an Operating System?
The OS as resource manager and abstraction layer — kernel vs user space, kernel architectures, the boot process, and what happens when the machine starts.
An operating system is the software layer between applications and hardware. It does two jobs:
- Referee (resource manager) — shares the CPU, memory, disks and network fairly and safely among many programs and users.
- Illusionist (abstraction provider) — turns messy hardware into clean abstractions: processes instead of CPU cores, virtual memory instead of physical RAM, files instead of disk blocks, sockets instead of network cards.
The core abstractions
| Hardware reality | OS abstraction | Lesson |
|---|---|---|
| A few CPU cores | Many concurrently running processes and threads | Processes, Threads |
| Limited physical RAM, shared | A private, huge virtual address space per process | Paging & virtual memory |
| Disk blocks | Files and directories | File systems |
| Network hardware | Sockets | Networks |
| Countless device types | Uniform interfaces (read/write, "everything is a file") | I/O systems |
Kernel mode and user mode
The CPU has privilege levels. The kernel runs in kernel mode (ring 0 on x86) and may do anything: touch any memory, talk to devices, change page tables. Applications run in user mode (ring 3), where privileged instructions fault.
Programs cross into the kernel only through controlled entry points:
- System calls — the program asks for a service (read a file, create a process).
- Exceptions — the program did something that needs handling (page fault, divide by zero).
- Interrupts — a device or timer needs attention.
That boundary is what keeps a buggy app from crashing the machine or reading another user's data. Details: System calls & the kernel.
Kernel architectures
| Design | Idea | Pros | Cons | Examples |
|---|---|---|---|---|
| Monolithic | Everything (FS, drivers, networking) runs in kernel space | Fast: direct function calls | A driver bug can crash the whole system | Linux, traditional Unix |
| Microkernel | Only the essentials (IPC, scheduling, memory) in the kernel; the rest are user-space servers | Isolation, reliability | IPC overhead | seL4, QNX, MINIX 3 |
| Hybrid | A monolithic core with some microkernel ideas | A compromise | Complexity | Windows NT, macOS XNU |
| Unikernel | The app and a minimal OS compiled into one image | Tiny, fast boot | Single app, harder to debug | MirageOS, Unikraft |
Linux mitigates the monolithic downside with loadable kernel modules (drivers loaded at runtime) and, increasingly, safe extension mechanisms like eBPF.
How a computer boots
- Firmware (UEFI, formerly BIOS) runs from flash on power-on: it tests hardware (POST) and finds a boot device.
- The bootloader (GRUB, systemd-boot, Windows Boot Manager) loads the kernel image and an initial RAM disk into memory.
- The kernel initialises: sets up memory management and page tables, detects hardware, starts drivers, mounts the root filesystem.
- The kernel starts the first user process, init (PID 1 —
systemdon most Linux distributions). - init starts services (networking, logging, the login manager, the GUI) and the system is ready.
What the OS does all day
- Schedules which thread runs on each core, switching hundreds or thousands of times a second (CPU scheduling).
- Handles page faults, mapping memory lazily as programs touch it.
- Services system calls for files, network, time, memory and processes.
- Handles interrupts from network cards, disks, keyboards and timers.
- Enforces security: users and permissions, process isolation, capabilities, sandboxes.
- Keeps accounts: CPU time, memory use, open files, resource limits (cgroups).
- The OS manages resources and provides abstractions: processes, virtual memory, files, sockets.
- The kernel runs in privileged mode; apps enter it via system calls, exceptions and interrupts.
- Monolithic kernels are fast; microkernels isolate components; most real systems are hybrids.
- Boot: firmware → bootloader → kernel → init (PID 1) → services.
QWhy do we need separate user and kernel modes?easy
Protection. If any program could execute privileged instructions or access any memory, one buggy or malicious program could corrupt the kernel or other processes. Hardware-enforced modes force programs to go through the kernel's checked interfaces.
QMonolithic vs microkernel — which is better?medium
It's a trade-off. Monolithic kernels avoid IPC overhead and are simpler to make fast; microkernels isolate failures and have a smaller trusted code base (seL4 is formally verified). Linux shows a monolithic kernel can be reliable in practice, while microkernels dominate safety-critical embedded systems.