Operating Systems — Overview
An operating system is the layer between your applications and the hardware. It manages the CPU, memory, storage, and devices so programs can run safely and efficiently. Understanding OS concepts makes you a better debugger, performance engineer, and systems designer.
The kernel is the core of the OS. It runs in privileged mode and handles the most sensitive tasks: process scheduling, memory allocation, device drivers, and file systems. User programs request kernel services through system calls.
| 1 | Application |
| 2 | │ |
| 3 | ▼ |
| 4 | User Space (your code, libraries, shell) |
| 5 | ─────────────────────────────────────── |
| 6 | Kernel Space (scheduler, memory manager, drivers) |
| 7 | ─────────────────────────────────────── |
| 8 | Hardware (CPU, RAM, disk, network) |
System calls are the API between user space and kernel space. Every time you open a file, send network data, or start a process, a system call happens behind the scenes.
| Call | Purpose |
|---|---|
| read | Read bytes from a file descriptor |
| write | Write bytes to a file descriptor |
| open | Open a file |
| close | Close a file descriptor |
| fork | Create a new process |
| exec | Replace process image |
| mmap | Map files or memory into address space |
| socket | Create a network socket |
info
A process is an instance of a running program with its own memory space. A thread is a unit of execution within a process; threads share the same memory but have separate stacks and registers.
| 1 | Process A |
| 2 | ├── Thread 1 (stack, registers) |
| 3 | ├── Thread 2 (stack, registers) |
| 4 | └── Shared: code, heap, open files |
Each process sees a private virtual address space. The OS maps virtual addresses to physical RAM (or swap on disk) using page tables. This isolation prevents processes from corrupting each other.
| Concept | Description |
|---|---|
| Virtual memory | Private address space per process |
| Physical memory | Actual RAM chips |
| Page | Fixed-size chunk of memory (often 4 KB) |
| Page fault | CPU interrupt when a page is missing or protected |
| Swap | Disk space used when RAM is full |
File systems organize data on storage devices. They provide naming, directories, permissions, and durability. Common Linux file systems include ext4, XFS, Btrfs, and ZFS.