Repository navigation
Operating Systems 11 interview qa
Mugundan edited this page Nov 27, 2026
·
1 revision
Relevant source files
The following references were used as context for generating this wiki page:
- Wikipedia: Operating system
- Book: Silberschatz, Galvin and Gagne, Operating System Concepts
- Book: Arpaci-Dusseau and Arpaci-Dusseau, Operating Systems: Three Easy Pieces (free online)
This page is for revision just before an interview. It puts the whole wiki on one diagram, lists the most common questions with short model answers grouped by topic, gives a checklist of the worked problems to practise, and ends with a glossary.
This page covers a one-picture summary, a quick-fire question bank, the "X vs Y" comparisons interviewers like, a problem-practice checklist and the glossary. It introduces no new ideas; each answer links to the page that explains it.
flowchart TD
OS["Operating system"] --> CPU["Sharing the CPU"]
OS --> MEM["Sharing memory"]
OS --> IO["Storage and devices"]
OS --> PROT["Protection"]
CPU --> PR["Processes: PCB, states, fork/exec"]
CPU --> TH["Threads: shared memory, own stack"]
CPU --> SC["Scheduling: FCFS, SJF, SRTF, RR, MLFQ"]
TH --> SY["Synchronization: mutex, semaphore, condvar"]
SY --> DL["Deadlock: 4 conditions, banker's"]
MEM --> PG["Paging, page tables, TLB"]
PG --> VM["Virtual memory: faults, FIFO/LRU/OPT,<br/>thrashing, copy-on-write"]
IO --> FS["File systems: inodes, links, journaling"]
IO --> DS["Disk scheduling, interrupts, DMA"]
PROT --> KM["User/kernel mode, system calls"]
KM --> KD["Monolithic vs microkernel"]
| Question | Short answer |
|---|---|
| Process vs program? | A program is code in a file; a process is it running, with memory, registers and resources (Processes) |
| Process vs thread? | Processes have separate address spaces; threads in a process share one, each with its own stack and registers (Threads) |
| What is a PCB? | The kernel's record of a process: PID, state, registers, PC, memory info, open files |
What does fork return? |
0 in the child, the child's PID in the parent, −1 on error |
fork() called 3 times in a row: how many processes? |
8 (7 new) |
exec vs fork? |
fork makes a copy; exec replaces the program in the current process (same PID) |
| Zombie vs orphan? | Zombie: finished, not yet reaped. Orphan: parent died, adopted by init |
| What is a context switch and why is it costly? | Saving one thread's state and loading another's; pure overhead plus cold caches and TLB |
| Fastest IPC? | Shared memory (but needs synchronization) |
| Question | Short answer |
|---|---|
| Turnaround, waiting, response? | Completion − arrival; turnaround − burst; first run − arrival (CPU Scheduling) |
| Which minimises average waiting time? | SJF (non-preemptive) / SRTF (preemptive), if bursts are known |
| Convoy effect? | Short jobs stuck behind a long one in FCFS |
| Starvation fix? | Aging |
| RR quantum too big / too small? | Becomes FCFS / too many context switches |
| How does MLFQ work? | Several priority queues; jobs that use a full quantum are demoted; periodic boost |
| Question | Short answer |
|---|---|
| Race condition? | Result depends on thread timing on shared data (Synchronization) |
| Critical section requirements? | Mutual exclusion, progress, bounded waiting |
| Mutex vs semaphore? | Mutex: owned lock for exclusion. Semaphore: counter any thread can signal |
| Spinlock vs mutex? | Spin for very short waits on multicore or where sleeping is impossible; otherwise sleep |
Why while around cond_wait? |
Spurious wakeups and condition already consumed by another thread |
| Four deadlock conditions? | Mutual exclusion, hold and wait, no preemption, circular wait (Deadlock) |
| Practical deadlock prevention? | Global lock ordering |
| Safe vs unsafe state? | Safe: some order lets every process finish. Unsafe: deadlock possible (not certain) |
| Priority inversion fix? | Priority inheritance |
| Question | Short answer |
|---|---|
| Internal vs external fragmentation? | Waste inside a block / waste between blocks (Memory Management) |
| Why paging? | No external fragmentation; any page in any frame |
| Translate an address? | Split into page number and offset; frame from page table; frame × size + offset |
| What is the TLB? | Cache of page-table translations |
| TLB miss vs page fault? | Miss: walk the page table. Fault: page not present or access not allowed |
| Page fault steps? | Trap, check address, get frame (evict if needed), read from disk, update table, restart (Virtual Memory) |
| FIFO vs LRU vs OPT? | Oldest loaded / least recently used / used furthest in future (best possible) |
| Bélády's anomaly? | More frames, more faults; FIFO only |
| Thrashing? | Working sets exceed RAM; constant paging |
| Copy-on-write? | Share pages read-only after fork; copy on first write |
| Question | Short answer |
|---|---|
| What is an inode? | File metadata and block pointers, no name (Files and I/O) |
| Hard vs soft link? | Same inode / file holding a path |
| Journaling? | Log changes and commit before applying, so crashes can be recovered |
| Polling vs interrupts vs DMA? | CPU checks / device signals / device moves data itself |
| SSTF vs SCAN? | Nearest first (may starve) / elevator sweep (no starvation) |
| System call path? | Trap instruction, kernel entry, dispatch table, checks, return (Kernel and System Calls) |
| Interrupt vs trap vs fault? | Asynchronous hardware / deliberate instruction / accidental instruction |
| Monolithic vs microkernel? | All services in kernel (fast) / minimal kernel, services in user space (robust) |
flowchart LR
A["Process"] <-->|"isolation vs sharing"| B["Thread"]
C["Mutex"] <-->|"ownership vs counting"| D["Semaphore"]
E["Paging"] <-->|"fixed vs variable size"| F["Segmentation"]
G["Hard link"] <-->|"inode vs path"| H["Soft link"]
I["Monolithic"] <-->|"speed vs isolation"| J["Microkernel"]
K["Preemptive"] <-->|"can interrupt vs cannot"| L["Non-preemptive"]
Answer every "X vs Y" with three things: what each is, the key difference, and when you would choose each.
| Problem | Worked example | Check yourself |
|---|---|---|
| Scheduling Gantt chart and averages | CPU Scheduling | FCFS 8.75, SJF 7.75, SRTF 6.50, RR(q=4) 11.75 average waiting |
Count fork processes |
Processes | 3 forks → 8 processes |
| Producer-consumer with semaphores | Synchronization |
empty = N, full = 0, mutex = 1; counting semaphore before mutex |
| Banker's safety check | Deadlock | Safe sequence P1, P3, P4, P0, P2 |
| Address translation | Memory Management | 0x3A7F with page 3 → frame 7 gives 0x7A7F |
| TLB effective access time | Memory Management | 90% hit, 100 ns memory: 110 ns |
| Page faults FIFO / LRU / OPT | Virtual Memory | 12-ref string, 3 frames: 10 / 9 / 7 |
| Bélády's anomaly | Virtual Memory | FIFO: 9 faults with 3 frames, 10 with 4 |
| Disk scheduling totals | Files and I/O | Head 53: FCFS 640, SSTF 236, LOOK 208 |
"What happens when you run ls?" |
Kernel and System Calls | Interrupt → read → fork → exec → syscalls → exit → wait |
flowchart LR
Q["Question"] --> D["Define the term<br/>in one sentence"]
D --> W["Explain how it works<br/>(draw a diagram)"]
W --> T["Give the trade-off<br/>or a trap"]
T --> E["Give a real example<br/>(Linux, Arm, a bug)"]
- Say your assumptions out loud (tie-breaking in scheduling, direction in disk scheduling, page-replacement tie rules).
- Draw: Gantt charts, state diagrams and frame tables make answers easy to follow and check.
- When writing synchronization code, explain why each lock or semaphore is there.
| Term | Meaning | Page |
|---|---|---|
| Aging | Raising a waiting process's priority over time to prevent starvation | CPU Scheduling |
| Banker's algorithm | Deadlock avoidance: grant a request only if a safe sequence remains | Deadlock |
| Bélády's anomaly | More frames causing more page faults (FIFO) | Virtual Memory |
| Burst time | CPU time a job needs before it blocks or ends | CPU Scheduling |
| Condition variable | Lets a thread sleep until signalled, used with a mutex | Synchronization |
| Context switch | Saving one thread's CPU state and restoring another's | Processes |
| Convoy effect | Short jobs delayed behind a long one in FCFS | CPU Scheduling |
| Copy-on-write | Share pages until written, then copy | Virtual Memory |
| Critical section | Code that accesses shared data | Synchronization |
| Deadlock | Threads waiting on each other forever | Deadlock |
| Demand paging | Loading pages only when first used | Virtual Memory |
| DMA | Device transfers data to memory without the CPU | Files and I/O |
| File descriptor | Per-process integer handle for an open file | Files and I/O |
| Fragmentation | Wasted memory: internal (inside blocks) or external (between) | Memory Management |
| Inode | File metadata and block locations, without the name | Files and I/O |
| Interrupt | Asynchronous hardware signal to the CPU | Kernel and System Calls |
| IPC | Inter-process communication: pipes, sockets, shared memory, signals | Processes |
| Journaling | Logging file-system changes before applying them | Files and I/O |
| Kernel mode | Privileged CPU mode for the OS | Overview |
| Livelock | Threads active but making no progress | Deadlock |
| MLFQ | Multilevel feedback queue scheduler | CPU Scheduling |
| MMU | Hardware that translates virtual to physical addresses | Memory Management |
| Monitor | Data plus lock plus condition variables, one thread inside at a time | Synchronization |
| Mutex | Lock providing mutual exclusion, with an owner | Synchronization |
| Orphan | Process whose parent has exited | Processes |
| Page / frame | Fixed-size block of virtual / physical memory | Memory Management |
| Page fault | Trap when an accessed page is not present or not allowed | Virtual Memory |
| Page table | Map from page numbers to frame numbers | Memory Management |
| PCB | Process control block | Processes |
| Preemption | Taking the CPU from a running thread | CPU Scheduling |
| Priority inversion | High-priority task blocked by a low-priority lock holder | Deadlock |
| Race condition | Outcome depends on thread timing | Synchronization |
| Round Robin | Each ready process runs for one quantum in turn | CPU Scheduling |
| Safe state | Some ordering lets all processes finish | Deadlock |
| Semaphore | Counter with atomic wait and signal | Synchronization |
| Spinlock | Lock that busy-waits | Synchronization |
| Starvation | A process never gets a resource | Deadlock |
| System call | Controlled entry from a program into the kernel | Kernel and System Calls |
| Thrashing | Constant paging; little useful work | Virtual Memory |
| Thread | Execution flow inside a process | Threads |
| TLB | Cache of address translations | Memory Management |
| Trap | Deliberate entry to the kernel by an instruction | Kernel and System Calls |
| Turnaround time | Completion − arrival | CPU Scheduling |
| Virtual memory | Each process sees a private address space, possibly larger than RAM | Virtual Memory |
| Waiting time | Turnaround − burst | CPU Scheduling |
| Working set | Pages a process used recently | Virtual Memory |
| Zombie | Finished process not yet reaped by its parent | Processes |
| Resource | Good for |
|---|---|
| Arpaci-Dusseau, Operating Systems: Three Easy Pieces (free online) | Clear beginner explanations of virtualisation, concurrency, persistence |
| Silberschatz, Galvin and Gagne, Operating System Concepts | The standard textbook; most interview problems come from here |
| The Wikipedia articles linked from each page | Quick refreshers |
| The Computer Architecture wiki | The hardware underneath: caches, memory ordering, multicore |
- Computer Architecture Overview
- Fundamentals: CPU, Memory and Instructions
- Pipelining
- Branches and Remedies
- Instruction-Level Parallelism
- Memory and Ordering
- Caches and Coherence
- Multicore
- Multithreading in Hardware
- SIMD and GPUs
- Glossary and Summary
- Hexagon Overview and Processor Properties
- ISA Fundamentals: Packets, Slots and Threads
- Registers
- Instruction Encoding and Mnemonics
- Data, Memory and Control Instructions
- Floating Point, HVX and Alignment
- Caches, MMU and Glossary
- Operating Systems Overview
- Processes
- Threads
- CPU Scheduling
- Synchronization
- Deadlock
- Memory Management
- Virtual Memory
- Files, Storage and I/O
- Kernel and System Calls
- Interview Q&A and Glossary
- C++ for LLVM Development: Overview
- C++ Basics
- Classes and RAII
- Ownership and Move Semantics
- Templates and Lambdas
- LLVM Data Structures (ADT)
- LLVM-Style RTTI: isa, cast, dyn_cast
- Errors, Output and Assertions
- Iterators and Ranges
- Building, Debugging and Exercises
- LLVM IR Overview
- Structure: Modules, Functions, Blocks and Values
- Type System
- Arithmetic, Bitwise and Cast Instructions
- Compare and Select
- Memory: alloca, load, store and getelementptr
- Control Flow: br, switch, ret and call
- SSA and Phi
- Control Flow Graph and Loops
- Dominance, Dominator Tree and Dominance Frontier
- Data-flow Analysis
- Writing an IR Pass
- Common Passes
- Exercises, Tooling and Glossary
- SelectionDAG Overview
- Pipeline, Phases and Traversal Orders
- Core Data Structures
- DAG Construction
- DAG Combiner
- Legalization
- Type Legalization
- Operation and Vector Legalization
- Instruction Selection
- TableGen Pattern Language
- Matcher Interpreter and Folding
- AArch64 Instruction Selection
- Scheduling and MIR Emission
- PHI Node Resolution
- AArch64 Walkthroughs
- Arithmetic and Data Movement
- Memory Instructions
- Control Flow and Calls
- End-to-End Example
- Tooling, Debugging and Extending
- Selector Comparison and Glossary
- Assignments: Build the Toy Backend
- Stage 1: Build Setup
- Stage 2: Target Registration
- Stage 3: TableGen Skeleton
- Stage 4: MC Layer for Assembly Output
- Stage 5: TargetMachine and Subtarget
- Stage 6: TargetLowering, Arguments and Returns
- Stage 7: Instruction Selection and the First Function
- Stage 8: Registers, Copies and Spills
- Stage 9: Frame Lowering
- Stage 10: Memory, Globals and Control Flow
- Stage 11: Calls
- Stage 12: Scheduling Model
- Stage 13: Object Files
- Stage 14: Capstone, a Complete Toy Backend
- Target Bring-up Overview
- Directory Layout, CMake and Registration
- The Target .td File
- TargetMachine and Subtarget
- TargetLowering Setup
- Calling Conventions
- Instructions and Instruction Selection
- Registers and Allocation Hooks
- Frame Lowering
- AsmPrinter and the MC Layer
- Scheduling
- A Minimal Toy Target
- Bring-up Checklist and AArch64 File Map
- Tooling and Glossary
- Calling Conventions Overview
- The CallingConv.td Language
- CCState and CCValAssign
- LowerFormalArguments
- LowerCall
- LowerReturn and CanLowerReturn
- Varargs, byval, sret and swifterror
- Tail Calls and Sibling Calls
- Custom Backend Guide and Checklist
- AArch64 Walkthroughs
- Tooling and Glossary
- Frame Lowering Overview
- MachineFrameInfo
- TargetFrameLowering Hooks
- The PEI Pass
- Callee-Saved Registers and Stack Layout
- Frame Index Elimination and the Register Scavenger
- Shrink Wrapping
- CFI and Unwind Information
- Custom Backend Guide and Checklist
- AArch64 Walkthroughs
- Tooling and Glossary
- MC Layer Overview
- Core Data Structures
- Streamers
- Assembler and Layout
- Fixups and Relocations
- Writing an MC Layer for a Custom Backend
- MCAsmInfo and the Instruction Printer
- Code Emitter
- AsmBackend and Object Writer
- Assembly Parser and Disassembler
- Bring-up Checklist and Common Failures
- Tooling and Glossary
- Register Allocation Overview
- The Register Allocation Pipeline
- Registers, Virtual Registers and Register Classes
- Liveness: Slot Indexes and Live Intervals
- Preparing Code for Allocation
- PHI Elimination and Two-Address Lowering
- Register Coalescer
- Allocation Framework
- The Register Allocators
- Fast Register Allocator
- Basic Register Allocator
- Greedy Register Allocator
- PBQP Register Allocator
- Spilling and Splitting
- Spill Weights and Copy Hints
- The Inline Spiller
- Live Range Splitting
- Rewriting and Post-RA Passes
- Writing Register Allocation Support for a Custom Backend
- Register Definitions in TableGen
- TargetRegisterInfo Hooks
- TargetInstrInfo Hooks
- Pass Pipeline Hooks
- Bring-up Checklist and Common Failures
- AArch64 Walkthroughs
- Tooling and Debugging
- Glossary and Where Do I Look