Operating System Concepts Every SDE Must Know

Process vs Thread

  • Process: Independent execution unit with its own memory space, file descriptors, and system resources.
  • Thread: Lightweight unit of execution within a process; shares memory space and resources.

CPU Scheduling Algorithms

  1. FCFS (First Come First Served): Non-preemptive; simple but can cause Convoy Effect.
  2. SJF (Shortest Job First): Minimizes average waiting time but requires knowing burst time in advance.
  3. Round Robin: Preemptive; each process gets a fixed time quantum; great for time-sharing.
  4. Priority Scheduling: Processes with highest priority run first; can cause starvation.

Page Replacement Algorithms

  1. FIFO: Replace the oldest page; simple but suffers from Belady's Anomaly.
  2. LRU (Least Recently Used): Replace the page not used for the longest time; optimal for locality of reference.
  3. Optimal (MIN): Replace the page that will not be used for the longest duration; impossible to implement in practice — used as a theoretical upper bound.