Operating Systems
Operating Systems tests how kernels multiplex CPU, memory, and I/O while preserving isolation and progress. Expect scheduling, synchronization, deadlock, virtual memory, and file-system questions.
Core rules
- A process has an address space; threads share it but have separate stacks and registers.
- Preemptive scheduling uses timer interrupts. Metrics: turnaround, waiting, response. SJF is optimal for average waiting time but needs burst prediction; RR bounds response time.
- Mutual exclusion needs atomic primitives. Semaphores and mutexes protect critical sections; monitors add condition variables.
- Deadlock requires mutual exclusion, hold-and-wait, no preemption, and circular wait. Breaking any one prevents it.
- Paging translates VPN to PFN via page tables; the TLB caches translations. Effective access time includes TLB lookup, memory access, and miss-path page walk.
Worked example
Three processes arrive at time 0 with bursts 6, 4, 2 under RR quantum 2. Execution order: P1(2), P2(2), P3(2), P1(2), P2(2), P1(2). Completion times: P1=12, P2=10, P3=6. Average turnaround = (12+10+6)/3 = 9.33; average waiting = turnaround − burst = (6+6+4)/3 = 5.33.
TLB example: lookup 2 ns, memory access 50 ns, miss rate 10%, page walk 20 ns. EAT = 2 + 50 + 0.10×20 = 54 ns. Lowering miss rate to 2% gives 52.4 ns.
Traps
- Forgetting arrival times in scheduling averages.
- Counting a page fault as a TLB miss only.
- Assuming more threads always improve throughput.
- Mixing deadlock avoidance with detection.