Home › Blog › Operating system interview questions with clear answers

Operating system interview questions with clear answers

Operating system interviews focus on how a computer runs many programs at once safely: processes versus threads, CPU scheduling, synchronisation and deadlocks, memory management with paging and virtual memory, and file systems. Campus interviews ask for definitions with examples; experienced and systems interviews ask how these concepts explain real behaviour, such as why a server slows under memory pressure or how a race condition corrupted data.

Fifteen common OS interview questions

  1. What is the difference between a process and a thread?
  2. What is a context switch, and why is it costly?
  3. Explain the main CPU scheduling algorithms.
  4. What is a deadlock, and what are its four necessary conditions?
  5. How can deadlocks be prevented, avoided or detected?
  6. Mutex versus semaphore?
  7. What is a race condition, and how do you prevent it?
  8. What is the critical section problem?
  9. What is paging? What is a page fault?
  10. What is virtual memory, and why use it?
  11. What is thrashing?
  12. Internal versus external fragmentation?
  13. What are system calls?
  14. User mode versus kernel mode?
  15. What happens when you run a program?

Processes, threads and scheduling

Deadlocks and synchronisation

A deadlock needs all four Coffman conditions: mutual exclusion, hold and wait, no preemption, and circular wait. Prevent it by breaking one — most practically, acquire locks in a fixed global order to remove circular wait. Avoidance algorithms such as the Banker's algorithm grant resources only when the system stays in a safe state. Detection builds a wait-for graph and breaks cycles by aborting or preempting.

PrimitiveUse
MutexOne thread at a time in a critical section; owned by the locking thread
Counting semaphoreUp to N concurrent users of a resource, such as a connection pool
Binary semaphoreSignalling between threads; not owned
Condition variableWait until a condition becomes true, used with a mutex
SpinlockVery short waits on multi-core systems; wastes CPU otherwise

Memory management

Paging splits virtual memory into fixed-size pages mapped to physical frames by a page table, removing external fragmentation (at the cost of some internal fragmentation in the last page). A page fault occurs when a page isn't in RAM and must be loaded from disk. Virtual memory gives each process its own large, isolated address space and lets the system use disk as overflow. When processes need far more memory than is available, the system spends most of its time swapping pages — thrashing — and throughput collapses. The TLB caches recent address translations to keep paging fast.

Kernel and user mode

User programs run in a restricted mode; privileged operations such as I/O and memory mapping require a system call that switches into kernel mode, where the OS performs the operation safely. This separation protects the system from buggy or malicious programs. “What happens when you run a program?” ties it together: the shell forks a process, exec loads the program, the loader maps it into memory, and the scheduler gives it CPU time.

Practising

Reading answers is not the same as saying them. Pick ten of the questions above and answer them aloud against a timer; a free AI interview assistant like CoPilot Interview can ask operating systems questions in a mock interview and flag answers that ran long or lacked an example. Pair this with Linux interview questions for the practical side, and computer networks questions for the rest of the core subjects.

Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly. Everything else on this page applies whichever tool you use, or none.

Frequently asked questions

What is the difference between a process and a thread?

A process has its own memory and resources; threads run within a process and share its memory while keeping their own stacks and registers, making them lighter but requiring synchronisation.

What are the four conditions for deadlock?

Mutual exclusion, hold and wait, no preemption and circular wait. Removing any one prevents deadlock; ordering lock acquisition removes circular wait.

What is virtual memory?

An abstraction giving each process its own large, isolated address space, mapped to physical memory by page tables, with disk used to hold pages that don't fit in RAM.

What is thrashing?

When the system spends most of its time moving pages between memory and disk because active processes need more memory than is available, so useful work collapses.

Practise on real interview questions

Run 145 real interview questions across 10 tracks, answer out loud and see a structured answer to compare with yours. Free, no signup.

Try a practice question