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
- FCFS (First Come First Served): Non-preemptive; simple but can cause Convoy Effect.
- SJF (Shortest Job First): Minimizes average waiting time but requires knowing burst time in advance.
- Round Robin: Preemptive; each process gets a fixed time quantum; great for time-sharing.
- Priority Scheduling: Processes with highest priority run first; can cause starvation.
Page Replacement Algorithms
- FIFO: Replace the oldest page; simple but suffers from Belady's Anomaly.
- LRU (Least Recently Used): Replace the page not used for the longest time; optimal for locality of reference.
- 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.