OS Interview Questions and Operating System Notes

How an OS manages processes, memory, scheduling, and synchronization, the concepts every backend and systems interview eventually touches.

51 topics across 6 categories, 205 interview questions

Top 10 OS interview questions with answers

  1. 1.What is an operating system, in one sentence?

    Software that manages hardware resources and provides a consistent interface for applications to run on top of.

    What Is an Operating System?
  2. 2.What's the key difference between a process and a thread?

    Processes have fully isolated memory from each other; threads within the same process share that process's memory, only getting their own separate stack and register state.

    Process vs Program vs Thread
  3. 3.What is a context switch?

    Saving the currently running process's complete execution state (into its PCB) and loading a different process's previously saved state, so the CPU can pause one process and resume another with no loss of correctness.

    Context Switching
  4. 4.What is a race condition, precisely?

    A situation where a program's correctness depends on the unpredictable relative timing of multiple processes or threads, rather than being guaranteed deterministically by the program's logic.

    Data Inconsistency and Race Conditions
  5. 5.What is a semaphore, and what two operations does it support?

    An integer variable manipulated only through atomic wait (decrement, block if negative) and signal (increment, wake a waiter) operations, used to control access to shared resources.

    Semaphores
  6. 6.What are the four necessary conditions for a deadlock?

    Mutual exclusion, hold and wait, no preemption, circular wait, all four must hold simultaneously.

    Deadlocks in Operating Systems
  7. 7.What problem does paging solve?

    External fragmentation, by allowing a process's memory to be scattered across non-contiguous physical frames instead of requiring one contiguous block.

    Paging in Operating Systems
  8. 8.What is virtual memory?

    A technique letting a process's address space, and the combined memory demand of all running processes, exceed the physical RAM actually installed, by keeping only actively-used pages in RAM.

    Virtual Memory and Demand Paging
  9. 9.What's the difference between internal and external fragmentation?

    External fragmentation is free memory scattered into unusable gaps between allocated blocks (a variable-size allocation problem); internal fragmentation is wasted space inside an allocated block that's bigger than what's actually needed (a fixed-size allocation problem).

    Fragmentation in Operating Systems
  10. 10.What's the core difference between preemptive and non-preemptive scheduling?

    Preemptive scheduling can forcibly interrupt a running process before it finishes or voluntarily yields; non-preemptive scheduling cannot, a process always runs to completion or until it blocks on its own.

    Preemptive vs Non-Preemptive Scheduling

All 205 OS interview questions

205 questions, grouped by topic. Each one is answered on its topic page, next to the explanation it comes from.

Process Scheduling

Process Scheduling

  1. What is the difference between the long-term and short-term scheduler?
  2. What are the typical goals a scheduler tries to balance?
  3. Name a real scheduler used in a production operating system.
  4. Why can't a scheduler optimize for every goal simultaneously?
Answers and notes

Scheduling Queues

  1. What's the difference between the job queue and the ready queue?
  2. What is a device queue?
  3. Describe the typical queue journey of a process that performs I/O.
  4. How does this relate to real process states you'd see in a tool like `top`?
Answers and notes

Preemptive vs Non-Preemptive Scheduling

  1. What's the core difference between preemptive and non-preemptive scheduling?
  2. Give an example of each.
  3. What real cost does preemption introduce?
  4. Why do virtually all modern general-purpose operating systems use preemptive scheduling?
Answers and notes

Scheduler vs Dispatcher

  1. What is the difference between the scheduler and the dispatcher?
  2. What is dispatch latency?
  3. Why does time slice length matter for a preemptive scheduler like Round Robin?
  4. Is the dispatcher part of the scheduling policy, or separate from it?
Answers and notes

Scheduling Criteria

  1. Name the standard scheduling criteria.
  2. What's the difference between turnaround time and waiting time?
  3. What's the difference between turnaround time and response time?
  4. Why can't a scheduler optimize all these criteria simultaneously?
Answers and notes

FCFS (First Come First Served) Scheduling

  1. What is FCFS scheduling?
  2. What is the convoy effect, and how does FCFS cause it?
  3. Is FCFS preemptive or non-preemptive?
  4. What's the main practical weakness of FCFS compared to something like SJF?
Answers and notes

Shortest Job First (SJF) Scheduling

  1. Is SJF preemptive or non-preemptive?
  2. Why is SJF called optimal, and optimal for what exactly?
  3. What's the biggest problem with SJF in practice?
  4. How would you fix starvation in SJF?
  5. Walk me through a Gantt chart for these four processes.
Answers and notes

SRTF (Shortest Remaining Time First) Scheduling

  1. What's the difference between SJF and SRTF?
  2. Why is SRTF considered even more optimal than non-preemptive SJF for average waiting time?
  3. What real-world limitation does SRTF share with SJF?
  4. Trace through what happens if a shorter process arrives while another is running.
Answers and notes

Priority Scheduling

  1. What is priority scheduling?
  2. What's the major risk of pure priority scheduling?
  3. How do you fix starvation in priority scheduling?
  4. How does Linux's real scheduler relate to this?
Answers and notes

Round Robin Scheduling

  1. What is Round Robin scheduling?
  2. What happens if the time quantum is too large or too small?
  3. Is Round Robin preemptive or non-preemptive?
  4. Why is Round Robin considered good for interactive systems specifically?
Answers and notes

Multilevel Queue Scheduling

  1. What is multilevel queue scheduling?
  2. What's a real risk of multilevel queue scheduling with strict inter-queue priority?
  3. How is this different from multilevel feedback queue scheduling?
  4. Give a real-world example of this idea.
Answers and notes

Multilevel Feedback Queue Scheduling

  1. How does multilevel feedback queue scheduling differ from plain multilevel queue scheduling?
  2. What causes a process to be demoted to a lower-priority queue?
  3. What's the key advantage of this approach over SJF or priority scheduling?
  4. Can a process move back up to a higher-priority queue?
Answers and notes

Starvation and Aging in Scheduling

  1. How can starvation occur in SJF, specifically?
  2. What is aging, precisely?
  3. Does aging change a process's real, declared priority, or just how it's treated by the scheduler?
  4. Is starvation the same problem in every scheduling algorithm?
Answers and notes

Introduction

What Is an Operating System?

  1. What is an operating system, in one sentence?
  2. Name the core responsibilities of an OS.
  3. Why can't applications just talk to hardware directly?
  4. What's the difference between an OS and a kernel?
Answers and notes

Types of Operating Systems

  1. What's the difference between a batch and a time-sharing OS?
  2. What is a real-time operating system, and what's the difference between hard and soft real-time?
  3. Give an example of where a real-time OS matters and why a normal OS wouldn't work there.
  4. What is a distributed operating system?
Answers and notes

RAM vs ROM

  1. What's the fundamental difference between RAM and ROM?
  2. Why can't a computer boot directly from RAM?
  3. Is ROM really unwritable?
  4. Why does RAM need to be fast if ROM doesn't?
Answers and notes

System Calls and APIs

  1. What is a system call?
  2. What's the difference between user mode and kernel mode?
  3. What's the difference between a system call and an API?
  4. Why are system calls relatively expensive?
Answers and notes

Virtualization vs Containerization

  1. What's the core difference between a VM and a container?
  2. Why do containers start faster than VMs?
  3. Which is more isolated, a VM or a container, and why?
  4. Why would a company use both together?
Answers and notes

BIOS vs UEFI

  1. What's the core difference between BIOS and UEFI?
  2. What is Secure Boot and why does it matter?
  3. Why can't BIOS boot from disks larger than 2TB as a single partition?
  4. Why does Windows 11 require UEFI?
Answers and notes

Important Terms in Operating Systems

  1. What's the difference between multiprogramming and multitasking?
  2. What is a kernel, and how is it different from 'the operating system'?
  3. What is spooling, and why does it help?
  4. What is an interrupt, and why not just poll devices in a loop instead?
Answers and notes

Monolithic Kernel vs Microkernel

  1. What's the core architectural difference?
  2. Why are monolithic kernels generally faster?
  3. Why are microkernels considered more stable/fault-tolerant?
  4. Is Linux monolithic or a microkernel?
Answers and notes

The Complete Booting Process

  1. Walk me through what happens between pressing the power button and reaching a login screen.
  2. What's the difference between the bootloader's job and the kernel's job?
  3. What is PID 1, and why does it matter?
  4. If a machine shows beep codes and never displays anything, what stage failed?
Answers and notes

Process Management

Processes in an Operating System

  1. What's the difference between a program and a process?
  2. What are the main states a process moves through?
  3. Why do two instances of the same program get separate processes instead of sharing one?
  4. What memory regions make up a process?
Answers and notes

Process vs Program vs Thread

  1. What's the key difference between a process and a thread?
  2. Why are threads considered 'lighter weight' than processes?
  3. What's the downside of threads sharing memory?
  4. Can two threads in the same process run on different CPU cores at the same time?
Answers and notes

Process Control Block (PCB)

  1. What is a Process Control Block?
  2. Why is the PCB essential for context switching?
  3. What information does a PCB typically hold?
  4. What is Linux's real equivalent of a PCB called?
Answers and notes

Context Switching

  1. What is a context switch?
  2. Why does context switching have overhead if it's 'just bookkeeping'?
  3. What triggers a context switch?
  4. Why is switching between threads generally cheaper than switching between processes?
Answers and notes

CPU-Bound vs I/O-Bound Processes

  1. What's the difference between a CPU-bound and an I/O-bound process?
  2. Why should a scheduler treat these two types differently?
  3. Give a real-world example of each.
  4. How does a scheduler like Linux's CFS account for this distinction?
Answers and notes

IPC and Pipes

  1. What is IPC, and why is it needed?
  2. What is a pipe, specifically?
  3. What's the difference between a pipe and a named pipe (FIFO)?
  4. Why is shared memory the fastest IPC mechanism, and what's the tradeoff?
Answers and notes

Zombie vs Orphan Process

  1. What is a zombie process?
  2. Is a zombie process still using CPU or memory?
  3. What is an orphan process, and what happens to it?
  4. How would too many zombie processes actually cause a problem?
Answers and notes

Important Terms Related to Processes

  1. What is turnaround time, and how is it different from waiting time?
  2. What is the degree of multiprogramming?
  3. What is dispatch latency, and why does it matter for real-time systems?
  4. How does process hierarchy relate to zombie and orphan processes?
Answers and notes

Process Synchronization

The Need for Process Synchronization

  1. Why is `counter++` not safe to run from multiple threads without synchronization?
  2. What is process synchronization trying to prevent?
  3. Give a real-world example of why this matters.
  4. Where in real systems is this problem actually solved in practice?
Answers and notes

Data Inconsistency and Race Conditions

  1. What is a race condition, precisely?
  2. Why is `counter++` unsafe across threads without synchronization, exactly?
  3. Why are race conditions hard to debug?
  4. How do you actually prevent a race condition?
Answers and notes

The Critical Section Problem

  1. What are the three requirements a correct critical section solution must satisfy?
  2. What is a critical section?
  3. Why isn't mutual exclusion alone considered a correct solution?
  4. What's the practical, real-world equivalent of the critical section problem in a database?
Answers and notes

Peterson's Solution

  1. What two variables does Peterson's Solution use, and what does each mean?
  2. Walk through why Peterson's Solution guarantees mutual exclusion.
  3. Why isn't Peterson's Solution used in real production systems today?
  4. What is Peterson's Solution's real educational value, then?
Answers and notes

Semaphores

  1. What is a semaphore, and what two operations does it support?
  2. What's the difference between a binary and a counting semaphore?
  3. Why must `wait` and `signal` be atomic?
  4. Give a real, practical use of a counting semaphore.
Answers and notes

Busy Waiting and Spinlocks

  1. What is busy waiting?
  2. What is a spinlock, and how does it relate to busy waiting?
  3. When is a spinlock actually a good choice, and when is it a bad one?
  4. Why would a spinlock never make sense on a single-core system?
Answers and notes

Deadlocks

Deadlocks in Operating Systems

  1. What are the four necessary conditions for a deadlock?
  2. If I remove one of the four conditions, is a deadlock still possible?
  3. How is a deadlock different from starvation?
  4. How would you detect a deadlock has occurred?
Answers and notes

Deadlock Prevention

  1. How do you prevent hold and wait?
  2. How do you prevent circular wait?
  3. What's the tradeoff of deadlock prevention compared to just letting deadlocks happen and detecting them?
  4. Why is mutual exclusion usually left alone in prevention strategies?
Answers and notes

Deadlock Avoidance

  1. What's the difference between deadlock avoidance and deadlock prevention?
  2. What is a safe state?
  3. What information does deadlock avoidance require that prevention doesn't?
  4. Is an unsafe state the same as a deadlock?
Answers and notes

Banker's Algorithm

  1. Walk me through how the Banker's Algorithm decides to grant or deny a request.
  2. What must a process declare before the algorithm can be used?
  3. Why is a request sometimes denied even though the resources are physically available?
  4. What's the time complexity concern with running the Banker's Algorithm frequently?
Answers and notes

Deadlock Detection

  1. How do you detect a deadlock?
  2. What are the two recovery strategies once a deadlock is detected?
  3. Why can't you just always terminate every process in the cycle?
  4. How does this relate to what real databases do?
Answers and notes

Deadlock Ignorance (The Ostrich Algorithm)

  1. What is the ostrich algorithm?
  2. Why do general-purpose OSes like Linux use this approach?
  3. When would the ostrich algorithm be a bad choice?
  4. Is this the same as not caring about deadlocks at all?
Answers and notes

Starvation in Operating Systems

  1. What's the difference between starvation and deadlock?
  2. How do you fix starvation?
  3. Can a system have starvation without ever having a deadlock?
  4. Give a real-world example of a starvation risk.
Answers and notes

Memory Management

Logical vs Physical Address Space

  1. What is the difference between a logical and a physical address?
  2. What component performs the translation?
  3. Why do processes use logical addresses instead of physical addresses directly?
  4. What happens if a process tries to access a logical address outside its allowed range?
Answers and notes

Swapping and Contiguous Memory Allocation

  1. What is contiguous memory allocation?
  2. What problem does contiguous allocation create over time?
  3. What is swapping?
  4. How does modern virtual memory relate to swapping?
Answers and notes

Fragmentation in Operating Systems

  1. What's the difference between internal and external fragmentation?
  2. Which allocation scheme causes which kind of fragmentation?
  3. How do you fix external fragmentation?
  4. Why do most modern operating systems accept internal fragmentation instead of external fragmentation?
Answers and notes

Paging in Operating Systems

  1. What problem does paging solve?
  2. Walk me through translating a logical address to a physical address under paging.
  3. What does a page table actually store?
  4. What is a TLB and why does it matter for paging performance?
Answers and notes

Segmentation in Operating Systems

  1. What's the difference between paging and segmentation?
  2. What does a segment table entry store?
  3. What happens if an offset exceeds a segment's limit?
  4. Why might segmentation be more natural for a compiler to reason about than paging?
Answers and notes

Virtual Memory and Demand Paging

  1. What is virtual memory?
  2. What is demand paging specifically?
  3. Why does demand paging work well given how real programs behave?
  4. What happens when a process accesses a page that isn't currently in RAM?
Answers and notes

Page Fault Handling

  1. What is a page fault?
  2. Walk me through the full sequence of steps when a page fault occurs.
  3. What's the difference between a legitimate page fault and an illegal memory access?
  4. What is thrashing and how does it relate to page faults?
Answers and notes

Page Replacement Algorithms

  1. Compare FIFO and LRU.
  2. What is the Optimal algorithm, and why can't it actually be implemented?
  3. Why doesn't Linux implement exact LRU?
  4. What is Belady's Anomaly?
Answers and notes

Frequently asked questions

Where do these os interview questions come from?

Each of the 205 questions comes from the "What interviewers actually ask" section of one of 51 Operating Systems topic notes. Every question links to its topic page, where it is answered next to the explanation it tests.

What does the Operating Systems section cover?

51 topics across 6 categories: How an OS manages processes, memory, scheduling, and synchronization, the concepts every backend and systems interview eventually touches.

Is it free to read?

Yes. Every article is free to read with no account required. Creating a free DevsUnite account lets you mark topics as read and track your progress across every Core Subjects article.