Operating Systems
Operating systems tests process and thread management, CPU scheduling, synchronization, deadlock, memory management, virtual memory, file systems, and disk scheduling. Numerical questions on scheduling and paging are common.
Core rules and concepts
- A process has its own address space; threads in the same process share code, data, and open files but have separate stacks and registers.
- Scheduling metrics: turnaround = completion − arrival; waiting = turnaround − burst. FCFS can cause convoy effect; SJF is optimal for average waiting time but needs burst prediction; round robin depends on quantum.
- Deadlock requires mutual exclusion, hold-and-wait, no preemption, and circular wait. Banker’s algorithm checks safety by simulating allocation to a state where all processes can finish.
- Paging eliminates external fragmentation but can cause internal fragmentation in the last page. TLB is a cache of page-table entries.
- Effective memory access time must include TLB lookup and, on a TLB miss, page-table access plus data access.
Worked example
TLB hit ratio is 90%, TLB access is 10 ns, and memory access is 100 ns. On a hit, time = 10+100=110 ns. On a miss, time = 10+100+100=210 ns, assuming one page-table level. EMAT = 0.9×110 + 0.1×210 = 99+21=120 ns. If the page table were multi-level, each additional level would add another memory access on the miss path.
Traps that cost marks
Calling a deadlock a starvation problem; forgetting that a spinlock wastes CPU; using the wrong page offset width; assuming FIFO page replacement is stack-based (it is not, so Belady’s anomaly is possible); and omitting TLB lookup time from EMAT.