Interview Prep — Operating Systems Track
OS Interview Questions
30 questions on processes, scheduling, virtual memory, concurrency, deadlocks, filesystems and I/O — with answers that survive follow-ups.
ProcessesMemoryConcurrencyScheduling
30Total Qs
9Beginner
14Intermediate
5Advanced
2FAANG
Questions
01
What is the difference between a program and a process?
Processes
Beginner
▾
A program is a passive file on disk; a process is that program in execution — with its own address space (code, data, heap, stack), registers, program counter, and a PCB the kernel tracks it with.
02
Process vs thread — one sentence.
Processes
Beginner
▾
A process is an isolated execution environment with its own address space; a thread is a lighter unit of execution inside a process that shares the address space but keeps its own stack and registers.
03
What is a Process Control Block (PCB)?
Processes
Beginner
▾
The kernel’s per-process bookkeeping record: PID, state, saved registers, memory map, open file descriptors, scheduling info. Context switches save into and restore from it.
04
Name the five classic process states.
Processes
Beginner
▾
New (being created), Ready (waiting for CPU), Running (on the CPU), Waiting (blocked on I/O or an event), Terminated (finished, awaiting cleanup). The scheduler cycles Ready ⇄ Running.
05
What is a system call, and why do user and kernel mode exist?
Boot
Beginner
▾
A controlled entry point into the kernel for privileged work (file I/O, process creation, networking). User mode can’t touch hardware or other processes’ memory; the mode split is what makes isolation and security enforceable.
06
Preemptive vs non-preemptive scheduling.
Scheduling
Beginner
▾
Preemptive: the OS can interrupt a running process when its time slice expires or a higher-priority task arrives. Non-preemptive: a process runs until it yields or blocks. All modern general-purpose OSes are preemptive.
07
What is virtual memory?
Memory
Beginner
▾
An abstraction giving each process its own private address space, mapped to physical frames by page tables. Enables isolation, overcommit (more virtual than RAM, spilling to disk), and shared pages like libraries.
08
What is a page fault?
Memory
Beginner
▾
A trap raised when a process touches a virtual page with no valid mapping. Minor: the page is in memory, just not mapped — fix the table. Major: load it from disk. Invalid: segfault.
09
Mutex vs semaphore.
Concurrency
Beginner
▾
A mutex is a lock with ownership — one holder, who must release it. A counting semaphore is a counter for N permits with wait/signal, no ownership — usable for signaling between threads, not just mutual exclusion.
10
Why does fork() return twice?
Processes
Intermediate
▾
fork() clones the caller. Execution resumes in both processes from the same point, so the one call returns in each: 0 in the child, the child’s PID in the parent — that return value is how the code tells them apart.
11
Zombie vs orphan process.
Processes
Intermediate
▾
Zombie: child exited but the parent hasn’t wait()ed — the dead entry lingers holding its exit status. Orphan: parent died first — the child is re-parented to init/systemd, which reaps it. Fix zombies by handling SIGCHLD or double-forking.
12
What makes a context switch expensive?
Scheduling
Intermediate
▾
Saving/restoring registers and the PC, switching page tables for a different process, and — the hidden cost — flushed TLB entries and cold CPU caches afterwards. Thread switches within a process skip the address-space swap, so they’re cheaper.
13
Round-robin: what happens if the time quantum is too small or too large?
Scheduling
Intermediate
▾
Too small: context-switch overhead dominates — throughput collapses. Too large: it degrades into FCFS and interactive latency dies. Rule of thumb: quantum much larger than switch cost, small enough to feel responsive (~ms range).
14
SJF is provably optimal for average waiting time — why don’t we use it?
Scheduling
Intermediate
▾
You can’t know burst lengths in advance, and long jobs starve while short ones keep jumping ahead. Real schedulers approximate it: MLFQ demotes CPU hogs, favoring short interactive bursts — SJF behavior without the crystal ball.
15
Paging vs segmentation.
Memory
Intermediate
▾
Paging chops memory into fixed-size pages — no external fragmentation, hardware-friendly, what everything uses. Segmentation uses variable-size logical units (code/heap/stack) — matches program structure but fragments; modern OSes are page-based.
16
What does the TLB do, and what happens on a miss?
Memory
Intermediate
▾
It caches virtual→physical translations so hits skip the page-table walk. A miss means walking a multi-level page table (several memory reads); the result is cached. This is why locality matters and why context switches hurt.
17
What is thrashing, and how do you detect it?
Memory
Intermediate
▾
The system spends more time servicing page faults than doing work — working sets exceed RAM, every process steals frames from the others. Signature: CPU utilization drops while disk I/O saturates. Fix: fewer processes, more RAM, or better locality.
18
Define race condition and critical section.
Concurrency
Intermediate
▾
Race: correctness depends on the interleaving of concurrent accesses to shared state. Critical section: the code touching that shared state, which must execute mutually exclusively — guarded by a mutex or made atomic.
19
Solve producer-consumer with semaphores.
Concurrency
Intermediate
▾
Three primitives:
empty counting free slots (init N), full counting filled (init 0), a mutex over the buffer. Producer: wait(empty), lock, insert, unlock, signal(full). Consumer mirrors it. Ordering of waits matters — swap them and you deadlock.
20
The four Coffman conditions for deadlock.
Deadlocks
Intermediate
▾
Mutual exclusion, hold-and-wait, no preemption, circular wait — all four must hold simultaneously. Break any one and deadlock is impossible; the practical one is circular wait, via global lock ordering.
21
Deadlock prevention vs avoidance vs detection.
Deadlocks
Intermediate
▾
Prevention: structurally break a Coffman condition (lock ordering). Avoidance: consider requests at runtime, grant only if the state stays safe (Banker’s). Detection: let it happen, find cycles in the wait-for graph, kill a victim — what databases do.
22
What is an inode? Hard link vs symlink.
Filesystems
Intermediate
▾
The inode holds a file’s metadata and block pointers — everything except its name. Hard link: another directory entry pointing at the same inode (equal peer, survives deleting the original). Symlink: a small file containing a path — can dangle, can cross filesystems.
23
What does a journaling filesystem protect against?
Filesystems
Intermediate
▾
Corruption from crashes mid-update. Changes are written to a journal first, then applied; on reboot, replay or discard incomplete transactions. Metadata journaling (default ext4) protects structure; full-data journaling protects contents at a write-amplification cost.
24
How does copy-on-write make fork() cheap?
Memory
Advanced
▾
fork() doesn’t copy memory — parent and child share all pages, marked read-only. Only when either writes does the kernel trap and copy that single page. fork+exec is nearly free since exec replaces the image anyway.
25
Explain the Banker’s algorithm in one breath.
Deadlocks
Advanced
▾
Grant a resource request only if, assuming every process may still demand its declared maximum, there exists some order in which all can finish — a “safe state”. If granting would leave no such order, block the request. Requires declared maximums, so it’s rarely used outside coursework.
26
select vs epoll — why does epoll win at 10k connections?
I/O
Advanced
▾
select scans the whole fd set every call: O(n) per event, plus copying the set in and out of the kernel. epoll registers interest once; the kernel pushes ready fds to a queue — O(1) per event regardless of connection count. That’s the C10k answer.
27
What is DMA and why do interrupts get coalesced?
I/O
Advanced
▾
DMA lets devices move data to/from RAM without the CPU copying byte-by-byte — the CPU sets up the transfer and gets one interrupt on completion. At high packet rates even that is too many interrupts, so NICs batch: one interrupt per group of packets (NAPI/polling hybrids).
28
Priority inversion — what is it and how is it fixed?
Concurrency
Advanced
▾
A low-priority thread holds a lock a high-priority thread needs, while medium-priority threads starve the low one — so the high-priority thread waits on the medium ones. Fix: priority inheritance — the lock holder temporarily gets the waiter’s priority. Famously hit the Mars Pathfinder.
29
Walk me from power button to shell prompt.
Boot
FAANG
▾
Firmware (UEFI) POSTs and loads the bootloader from the EFI partition → bootloader (GRUB) loads kernel + initramfs → kernel initializes hardware, mounts root, starts PID 1 → init/systemd brings up services in dependency order → getty/display manager → login → your shell. Know which stage to blame when boot hangs.
30
Design a thread pool — what are the key decisions?
Concurrency
FAANG
▾
Pool size (CPU-bound: ~cores; I/O-bound: larger, or work-stealing), a bounded task queue (unbounded queues hide overload — prefer backpressure or rejection policy), shutdown semantics (drain vs abort), and avoiding deadlock from tasks that submit and wait on other tasks in the same pool.
No questions match your filter.