Operating Systems Interview Questions: Processes, Memory and Deadlocks with Worked Answers
Turn isolated OS definitions into clear interview answers through five worked traces covering processes, scheduling, memory, synchronisation and deadlock safety.
KnowledgeGate Team
Exam prep & CS education

You may remember every definition and still freeze when an interviewer asks, "Show me the state change", "Calculate the wait", or "Why is this unsafe?" The missing skill is usually not recall but reasoning aloud. A reliable answer defines the concept, names the mechanism, traces one example and states the trade-off.
1. Build Every OS Interview Answer in Four Layers
Build each answer by defining the term, naming the mechanism or data structure, tracing one example, then stating the trade-off.
For example, "A process is a program in execution" is only layer one. Complete it with the PCB, Ready/Running/Waiting transitions, one scheduling event, and the cost of a context switch.
Ask five questions while practising: When does Running return to Ready? How does the quantum affect waiting? How do VPN and offset form an address? Why does semaphore order matter? Why can unsafe differ from deadlocked? Practise this delivery structure with the Interview & Resume Preparation Course.
2. Processes, Threads and the Five-State Model
A program is passive code. A process is an executing instance with an address space and OS-managed resources. Its threads share code, data and open resources, but each keeps a program counter, registers and stack. The PCB stores process-level state, program counter, registers and scheduling metadata.
Trace P1:
It is admitted from New to Ready at
t=0 msand dispatched to Running att=1 ms.It requests disk I/O at
t=4 ms, so it enters Waiting untilt=7 ms.I/O completion returns it to Ready, not directly to Running. It is dispatched again at
t=9 msand exits to Terminated att=12 ms.
A timer expiry sends Running to Ready; an I/O request sends Running to Waiting. A context switch saves the outgoing context and restores the incoming one. It costs CPU time without progressing user work, and its duration depends on the machine and OS.

3. CPU Scheduling Worked Answer: Round Robin With Arrivals
Use a 2 ms quantum with P1(arrival 0, burst 5), P2(arrival 1, burst 3) and P3(arrival 2, burst 1). If a process arrives exactly at a quantum boundary, place it in the ready queue before requeuing the pre-empted process.
The schedule is:
0-2 P1 | 2-4 P2 | 4-5 P3 | 5-7 P1 | 7-8 P2 | 8-9 P1
Completion times are C1=9, C2=8, C3=5 ms. Therefore:
Process | Turnaround time | Waiting time | Response time |
|---|---|---|---|
P1 |
|
|
|
P2 |
|
|
|
P3 |
|
|
|
Average waiting time is (4+4+2)/3 = 10/3, about 3.33 ms. Average response time is (0+1+2)/3 = 1 ms.
Excluding initial dispatch, the five switches are P1->P2, P2->P3, P3->P1, P1->P2, P2->P1. A smaller quantum may improve responsiveness but create more switching overhead. Once the arrival-boundary rule is clear, use the CPU scheduling algorithms explainer to compare FCFS, SJF, Priority and Round Robin with Gantt charts.
4. Virtual Memory Worked Answer: Translate an Address and Compute EAT
A 16-bit virtual address with 1 KiB = 2^10 bytes per page has a 10-bit offset and a 6-bit VPN. For VA = 0x3A6D = 14,957:
VPN = floor(14,957/1,024) = 14.offset = 14,957 - 14x1,024 = 621 = 0x26D.If valid entry
VPN 14 -> PFN 5, thenPA = 5x1,024 + 621 = 5,741 = 0x166D.
Now assume a sequential TLB lookup of 10 ns, memory access of 100 ns, a 95% hit ratio, one in-memory page-table access on a miss, and no page fault. A hit costs 10+100=110 ns; a miss costs 10+100+100=210 ns. Thus:
EAT = 0.95x110 + 0.05x210 = 104.5 + 10.5 = 115 ns
Without a TLB, this single-level model takes 200 ns for a page-table access plus data access. Do not add disk time because this case excludes faults. A page is a fixed-size virtual unit, a frame is its same-sized physical unit, and a page fault means the page is not resident. Master the single-address EAT calculation first; the memory management, paging and segmentation then contrasts paging, TLB and segmentation more broadly.

5. Synchronisation Worked Answer: Correct and Incorrect Semaphore Order
For a buffer of capacity 2, start with empty=2, full=0, mutex=1.
Producer:
wait(empty): 2->1,wait(mutex): 1->0, insertA,signal(mutex): 0->1,signal(full): 0->1.Consumer:
wait(full): 1->0,wait(mutex): 1->0, removeA,signal(mutex): 0->1,signal(empty): 1->2.
Order is part of correctness. On an empty buffer, an incorrect consumer calls wait(mutex) first, changes mutex 1->0, then blocks on full=0. A producer changes empty 2->1 but blocks on mutex=0. Neither can signal what the other needs, so this is circular wait, not merely a race condition. mutex gives mutual exclusion; empty and full give condition synchronisation.
6. Deadlock Worked Answer: Conditions, Safe State and Unsafe Grant
The four Coffman conditions are mutual exclusion, hold and wait, no pre-emption, and circular wait. Suppose T1 holds L1 and requests L2, while T2 holds L2 and requests L1. With one instance of each, the cycle is a deadlock. Requiring L1 before L2 breaks this circular wait.
For a Banker's check, start with Available=[1,0]:
Process | Allocation | Max | Need |
|---|---|---|---|
P0 |
|
|
|
P1 |
|
|
|
P1 can finish first and release [0,1], making Work=[1,1]. Then P0 can finish. The safe sequence is P1, P0.
Now let P0 request [1,0]. The request is within both its Need and current Available. A provisional grant leaves Available=[0,0], P0 Need=[0,1], and P1 Need=[1,0]. Neither can finish, so no safe sequence remains and Banker's algorithm refuses the grant. Unsafe means there is no guaranteed safe sequence under the declared maximum demands. It does not mean deadlock has already occurred.
7. Interview Traps: Similar Terms Need Different Answers
Process versus thread is resource ownership versus an execution path.
Concurrency versus parallelism is overlapping progress versus simultaneous execution.
Paging versus segmentation is fixed-size mapping versus logical variable-size regions.
Internal versus external fragmentation is waste inside allocated units versus unusable gaps between allocations.
Deadlock means a set cannot progress because each waits for another. Starvation means one participant may be postponed indefinitely while the system progresses. Livelock means participants change state but complete no useful work. Round Robin resists starvation through repeated turns, but not every policy eliminates it.
Avoid four shortcuts. A TLB caches translations, not pages. A cycle proves deadlock only under resource-instance assumptions. I/O completion moves Waiting to Ready, not Running. Quote 115 ns only with its timing model and no-page-fault assumption.
8. How to Practise the Reasoning Chain
Use this as a 20-minute oral drill:
Minutes
0-4: redraw the five-state model and narrate theP1trace.Minutes
4-9: rebuild the Round Robin chart and derive3.33 msaverage waiting time.Minutes
9-13: translate0x3A6Dto0x166Dand derive115 ns.Minutes
13-16: trace the buffer semaphores.Minutes
16-20: proveP1, P0is safe, then explain why granting[1,0]toP0is unsafe.
For additional practice, rotate through Process Management, CPU Scheduling, Memory Management, Virtual Memory, Process Synchronization and Deadlock. Recalculate each trace before checking an explanation.
The short version is: define, trace, calculate, then name the trade-off. Use CS Fundamentals for Placements by Sanchit Sir for core-CS revision and the Resume & Interview Preparation category for interview-planning guidance. Then return to the interview course and answer aloud.
Keep learning

Placement Mock Analysis: One Error Ledger Across Every Test Round
Use one error ledger without flattening unlike round results. This worked example shows how to find the first wrong step, prioritise repairs and close errors only after fresh retests.

Internship to PPO: Build a Weekly Evidence Trail Before the Final Review
Use a weekly outcome ledger to make your internship work visible before the final review. This practice model shows how to record delivery, feedback, effect and handoff honestly.

DSA Mock Interview Rubric: A 100-Point Scorecard for Reasoning, Code and Communication
A practical six-part scorecard for running comparable DSA mocks, grading visible evidence and turning weak areas into the next week's practice.

Campus Recruitment Timeline: Stage by Stage from Pre-Placement Talk to Written Offer
Follow a campus drive without guessing. Build an evidence sheet, verify eligibility, plan each preparation window and check the written offer before responding.