All cheat sheets
⚙️
Operating Systems
Processes, threads, scheduling, memory, deadlocks — interview essentials.
Process vs Thread
| Process | Independent program in execution; own address space; heavy context switch. |
|---|---|
| Thread | Lightweight unit within a process; shared memory; faster context switch. |
| PCB | Process Control Block stores PID, state, registers, memory info, I/O status. |
| Context switch | Save/restore CPU state when scheduler switches processes/threads. |
CPU Scheduling
| FCFS | First Come First Serve — simple, convoy effect possible. |
|---|---|
| SJF | Shortest Job First — optimal avg waiting; needs prediction. |
| Round Robin | Time quantum; fair; quantum too small → thrashing switches. |
| Priority | Static/dynamic priorities; risk of starvation → aging. |
Memory & Deadlock
| Paging | Fixed-size pages; external fragmentation avoided; page table overhead. |
|---|---|
| Virtual memory | Use disk as extension of RAM; demand paging + page faults. |
| Deadlock 4 | Mutual exclusion, hold & wait, no preemption, circular wait. |
| Banker's algo | Avoidance: allocate only if system stays in safe state. |