Operating Systems Cheatsheet

Overview

Use this Operating Systems reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.

What is an Operating System?

An operating system (OS) is system software that manages hardware resources and provides services to application programs. It acts as an intermediary between users/applications and the computer hardware. OS knowledge explains why code slows down, crashes, blocks on I/O, runs safely in separate processes, and behaves differently under load.

An OS provides an environment in which programs can run. It is both a resource allocator (decides how to allocate resources efficiently and fairly) and a control program (controls execution of programs to prevent errors and misuse).

Core OS Roles

RoleDescriptionExample
Resource ManagerAllocates CPU, memory, I/OScheduler assigns CPU time
Abstract MachineHides hardware complexityread() hides disk geometry
Protection BoundaryIsolates processes from each otherVirtual address spaces
Interface ProviderExposes system calls to programsPOSIX API
Daemon SupervisorManages background servicessshd, cron, systemd

Kernel vs User Space

┌──────────────────────────────────────┐
│   User Space (unprivileged)          │
│   Applications, shells, libraries    │
├──────────────────────────────────────┤
│   System Call Interface              │
├──────────────────────────────────────┤
│   Kernel Space (privileged)          │
│   Process mgmt · Memory · FS · I/O  │
├──────────────────────────────────────┤
│   Hardware Abstraction Layer (HAL)   │
├──────────────────────────────────────┤
│   Physical Hardware                  │
└──────────────────────────────────────┘

Kernel mode (ring 0 on x86): full CPU instruction access, direct hardware control. User mode (ring 3 on x86): restricted; crossing to kernel requires a system call trap.

OS Architectures

ArchitectureDescriptionExamplesPros / Cons
MonolithicAll OS services in one kernel binaryLinux, FreeBSDFast; large attack surface
MicrokernelMinimal kernel; services as user processesMinix, QNX, MachFault-isolated; IPC overhead
HybridMonolithic with some isolationWindows NT, macOS XNUBalance of perf + modularity
ExokernelExposes raw hardware; library OSes handle abstractionsMIT ExokernelMax flexibility; complex
UnikernelApp + OS compiled together, no user/kernel splitMirageOSTiny footprint; no isolation

System Boot Sequence (x86/UEFI)

  1. Power-on → CPU fetches reset vector
  2. UEFI/BIOS firmware initializes hardware (POST)
  3. Boot loader (GRUB/bootmgr) loaded from EFI partition
  4. Boot loader loads kernel image + initial ramdisk (initrd)
  5. Kernel unpacks, initializes subsystems, mounts real root FS
  6. PID 1 launched (systemd / init)
  7. System services started; login prompt presented

Privilege Levels (x86 Rings)

RingNameUsed ByCan Access
0KernelOS kernelAll instructions, all memory
1–2(unused in modern OSes)
3UserApplicationsUnprivileged instructions only

Interrupt-Driven OS Design

  • Hardware interrupt: external device signals CPU (keyboard, NIC, timer)
  • Software interrupt / trap: deliberate (int 0x80, syscall)
  • Exception: CPU detects error (divide by zero, page fault)
Device → IRQ line → PIC/APIC → CPU interrupt pin
CPU: save state → disable interrupts → jump to ISR
ISR: handle event → re-enable → IRET (restore state)

Key Data Structures Maintained by the OS

StructurePurpose
Process Control Block (PCB)Per-process state (PID, registers, page table ptr, …)
Ready QueueProcesses waiting for CPU
Device QueueProcesses waiting on I/O
Open File TablePer-process + global file descriptors
Page TableVirtual → physical address mapping
Interrupt Descriptor Table (IDT)Maps interrupt vectors to handler routines

OS Services Summary

  • Program execution — load, run, terminate programs
  • I/O operations — abstract device access
  • File-system manipulation — create, delete, read, write files/directories
  • Communications — pipes, sockets, shared memory
  • Error detection — hardware faults, arithmetic errors, process errors
  • Resource allocation — CPU cycles, memory, I/O bandwidth
  • Accounting — track resource usage per user/process
  • Protection & security — access control, authentication