Ask a fresher "what is a process" and the definition is usually easy. The useful follow-up is: "if context switches are cheap, why does adding more processes eventually make the machine slower?" That question tests whether the candidate can connect switching, cache effects and paging instead of reciting isolated definitions.
This post gives you 50 operating system interview questions to prepare, organised as follow-up chains. The core chains (process vs thread, context-switch cost, paging to thrashing, deadlock handling) are answered at whiteboard depth, with the follow-up probes named, and the rest are listed as stems you should be able to answer in two or three sentences each.
Operating system interview questions: how the follow-up chain works
An OS round can start with a definition, then probe whether you understand its consequences. A useful chain runs from process vs thread to context-switch cost, then to what happens when the system spends more time switching or paging than doing useful work. Reaching thrashing cleanly demonstrates that the concepts connect.
Our published question bank holds close to two thousand Operating System questions, and its densest pools cover the same core concepts. Use that density as a practice priority, not as a survey of employer interviews, on the Operating System learn module.
Topic pool | Published questions in our bank | Practice priority |
|---|---|---|
CPU Scheduling | about 290 | High |
Virtual Memory | about 260 | High |
Memory Management | about 220 | High |
Process Synchronization | about 200 | High |
Deadlock | about 165 | High |
Threads and Process Creation | about 125 | Medium |
Process and thread interview questions (Q1 to Q10)
Q1. What is the difference between a process and a thread? A process is a program in execution with its own address space: code, data, heap, and stack, tracked by the OS in a process control block. Threads are execution units inside a process that share the code, data, and heap but keep a private stack, register set, and program counter. Because threads share an address space, creating one and switching between them is cheaper than for processes. Follow-up probe: "cheaper how, exactly?" That is Q2.
Q2. What happens during a context switch, and what does it cost? The kernel saves the running task's CPU state (registers, program counter, stack pointer) into its PCB, picks the next task, and restores that task's state. The direct cost is the save, restore, and scheduler work. The larger indirect cost is that caches and the TLB now hold the wrong task's data, so the new task starts with misses. Follow-up probe: "is a thread switch cheaper than a process switch?" Yes, switching threads of the same process keeps the address space, so the page-table base does not change and the TLB does not need flushing.
Q3. Draw the process state diagram. New, ready, running, waiting (blocked), terminated. Running to ready happens on preemption; running to waiting happens when the process requests I/O or an unavailable resource. The probe here is the difference between ready and waiting: ready means it lacks only the CPU, waiting means it cannot use the CPU even if offered.
Be ready with short answers for the rest of the pool:
Q4. What does a PCB contain?
Q5. User-level vs kernel-level threads, and who schedules each.
Q6. What does fork() return, and how many processes exist after n forks?
Q7. Zombie vs orphan processes.
Q8. fork() vs exec().
Q9. Name IPC mechanisms: pipes, shared memory, message queues, sockets.
Q10. Mode switch vs context switch.
CPU scheduling interview questions (Q11 to Q18)
Q11. Preemptive vs non-preemptive scheduling. Non-preemptive lets a process keep the CPU until it blocks or finishes (FCFS, non-preemptive SJF). Preemptive can take the CPU away on a timer interrupt or a higher-priority arrival (round robin, SRTF, preemptive priority). Follow-up probe: "why does the round robin time quantum matter?" Too small and the CPU spends its time context switching; too large and round robin degrades into FCFS.
Q12. What is the convoy effect, and why is SJF called optimal? In FCFS, one long CPU-bound process makes every short process behind it wait, like cars behind a truck. SJF gives the minimum average waiting time, but it needs the next CPU burst length, which must be predicted (usually by exponential averaging), and pure SJF can starve long jobs. The fix for starvation is aging: gradually raising the priority of waiting processes.
Quick-fire stems:
Q13. Compute turnaround and waiting time for a given FCFS, SJF, SRTF, or RR table.
Q14. Turnaround time vs waiting time vs response time.
Q15. Multilevel queue vs multilevel feedback queue.
Q16. Scheduler vs dispatcher.
Q17. Long-term, short-term, and medium-term schedulers.
Q18. Starvation vs deadlock.
Synchronization and deadlock interview questions (Q19 to Q31)
Q19. What is a race condition, and what must a critical-section solution guarantee? A race condition is when the result depends on the interleaving of concurrent accesses to shared data. A correct critical-section solution guarantees mutual exclusion, progress, and bounded waiting. Interviewers often probe with a lost-update example: two threads incrementing a shared counter can lose increments because load, add, store is not atomic.
Q20. Mutex vs semaphore. A mutex is a lock with ownership: the thread that locks it must unlock it, and it protects a critical section. A semaphore is a signalling counter with wait and signal operations; a counting semaphore manages n identical resources, and any thread may signal it. Follow-up probe: solve producer-consumer with semaphores (empty, full, and a mutex) and explain why the wait order matters.
Q21. What are the four conditions for deadlock, and how do prevention, avoidance, and detection differ? Deadlock needs mutual exclusion, hold and wait, no preemption, and circular wait to hold simultaneously. Prevention structurally breaks one condition, most practically by imposing a total order on resource acquisition. Avoidance (the Banker's algorithm) grants a request only if the resulting state is safe, meaning a sequence exists in which every process can finish. Detection lets deadlock happen; with single-instance resources, a cycle in the wait-for graph detects it, while more general cases use allocation and request data. Recovery may abort a process or preempt a resource. The natural follow-up is: "every deadlocked state is unsafe, but is every unsafe state deadlocked?" No.
Round out the pool:
Q22. Binary vs counting semaphore.
Q23. Peterson's solution and what it guarantees.
Q24. Spinlock vs sleeping lock, and when spinning is acceptable.
Q25. Priority inversion and priority inheritance.
Q26. Livelock vs deadlock.
Q27. Readers-writers problem and writer starvation.
Q28. Dining philosophers and how lock ordering fixes it.
Q29. Reading a resource-allocation graph for deadlock.
Q30. Safe vs unsafe state in the Banker's algorithm.
Q31. How would you avoid deadlock in multithreaded code you write? (Answer: consistent lock ordering.)
Memory management and virtual memory interview questions (Q32 to Q43)
Q32. How does paging work? Physical memory is split into fixed-size frames and logical memory into pages of the same size. A page table maps page numbers to frame numbers, so a logical address (page number, offset) becomes (frame number, offset). Paging removes external fragmentation but keeps internal fragmentation in the last page. Follow-up probe: "every memory access now needs a page-table lookup too, so is memory twice as slow?" No, the TLB caches recent translations; only a TLB miss pays the extra access.
Q33. What happens on a page fault? The MMU traps to the OS, which checks the reference is valid, finds a free frame (or evicts one using a replacement policy), schedules a disk read for the page, updates the page table, and restarts the faulting instruction. This is demand paging: pages load only when touched.
Q34. What is thrashing, and how do you stop it? Thrashing is when processes spend more time servicing page faults than executing, because too many processes are competing for too few frames and none holds its working set. The trap question: CPU utilisation drops, so a naive scheduler admits more processes, which makes it worse. This is the end of the chain that started at Q1: switching and paging are cheap individually, and pile-ups of them are what kill performance. Fixes: working-set-based allocation, page-fault-frequency control, or reducing the degree of multiprogramming.
Remaining stems:
Q35. Internal vs external fragmentation.
Q36. Paging vs segmentation.
Q37. First fit, best fit, worst fit.
Q38. FIFO, LRU, and Optimal page replacement on a given reference string.
Q39. Belady's anomaly and which algorithms suffer it.
Q40. Effective access time with a TLB hit ratio.
Q41. Swapping vs paging.
Q42. What virtual memory buys you beyond "more memory".
Q43. Copy-on-write in fork().
File system, disk, and quick-fire questions (Q44 to Q50)
These come as warm-ups or closers, and a crisp two-sentence answer to each is enough:
Q44. What is a system call, and what happens when one executes (user to kernel mode)?
Q45. What is an inode, and what does it store?
Q46. Compare FCFS, SSTF, SCAN, and C-SCAN disk scheduling.
Q47. Buffering vs caching vs spooling.
Q48. Monolithic kernel vs microkernel.
Q49. What happens from power-on to login (the boot sequence)?
Q50. Why does a long-running system slow down, and what roles do fragmentation and caching play?
How to prepare these 50 questions in two weeks
Do not memorise stems. Learn the five chains (process to thread to context switch, scheduling trade-offs, synchronization to deadlock, paging to thrashing, and the quick-fire layer) so the follow-up probe is a continuation, not an ambush. Then practise against real questions until each chain is routine; the Placement Preparation category collects the rest of your drive prep alongside it.
If you want the whole subject sequenced for you, Computer Science Fundamentals for Placements by Sanchit Sir covers Operating Systems in about six and a half hours of instructor-led video with company-tagged MCQs (TCS, Infosys, Wipro, Cognizant and more), alongside DBMS, Computer Networks, and Software Engineering, with a day-by-day planner. If you only need OS revision, work the learn module and its question pools directly.
Answer the whiteboard-depth questions out loud, by hand, at least once. An interviewer is not checking whether you have read about thrashing. They are checking whether you can walk there from "what is a process" without being carried.




