Rapid Revision · Technical

Operating Systems

OS questions test whether you understand what really happens when programs run. These are the answers interviewers expect, in the words you can actually say.

The 3-minute recap

If you read nothing else tonight, read these 6 lines.

  • Process = program in execution with its own memory; thread = unit of execution inside it.
  • Deadlock needs all 4 Coffman conditions; break any one to prevent it.
  • Mutex = lock with ownership; semaphore = counter, no ownership.
  • Paging removes external fragmentation but brings internal fragmentation.
  • Thrashing = more time paging than executing; fix by reducing multiprogramming.
  • System calls are the only doorway from user mode into the kernel.

Work through the cards

11 cards, each one idea: what it is, a worked example, and the trap to dodge.

Process vs thread?

A process is a program in execution with its own address space, file handles and at least one thread. A thread is the unit of CPU scheduling inside a process; threads of one process share code, data and heap. Context switching between threads is cheaper because the address space does not change.

Trap: If you say threads share memory, expect: what do they NOT share? Their own stack, registers and program counter.

Process lifecycle and the PCB?

States: new, ready, running, waiting, terminated. The OS tracks each process in a Process Control Block: PID, state, program counter, registers, memory info, open files. A context switch saves one PCB and loads another.

Running to waiting happens on an I/O request; waiting to ready when the I/O completes.

Trap: A process never jumps from waiting straight to running; it must pass through ready.

Scheduling algorithms?

FCFS runs jobs in arrival order, simple but long jobs block short ones (convoy effect). SJF gives minimum average waiting time but needs to know burst lengths and can starve long jobs. Round Robin gives each process a time slice, great for responsiveness. Priority runs the highest priority first and risks starvation, fixed by aging.

Trap: Follow-up: what happens in RR when the quantum is huge? It degrades to FCFS. Tiny quantum? Context-switch overhead dominates.

What is a deadlock?

Processes waiting on each other in a cycle, forever. Requires all four Coffman conditions at once: mutual exclusion, hold and wait, no preemption, circular wait. Prevent by breaking one condition; avoid with Banker's algorithm, which only grants a request if the system stays in a safe state.

Classic prevention: impose a global lock ordering, killing circular wait.

Trap: Prevention vs avoidance vs detection are three different strategies; know which is which.

Mutex vs semaphore?

A mutex is a lock with ownership: only the thread that locked it may unlock it, and only one thread holds it at a time. A semaphore is a counter with wait and signal; any thread may signal, and a counting semaphore can admit N threads. Binary semaphore looks like a mutex but has no ownership.

Producer-consumer uses two counting semaphores (empty, full) plus a mutex around the buffer.

Trap: Expect: can a semaphore initialised to 1 replace a mutex? Functionally close, but no ownership means any thread can release it, which is unsafe.

Paging vs segmentation?

Paging cuts memory into fixed-size frames and the process into same-size pages; a page table maps them, eliminating external fragmentation but wasting part of the last page (internal fragmentation). Segmentation cuts the program by logical units (code, stack, heap) of variable size, matching the programmer's view but causing external fragmentation.

Trap: Fragmentation direction is the favorite probe: paging = internal, segmentation = external.

Virtual memory and thrashing?

Virtual memory lets a process run with only some pages in RAM, using disk for the rest, enabling programs bigger than physical memory. A page fault loads the missing page. Thrashing is when processes fault so often the CPU mostly waits on the disk; throughput collapses. Cure: fewer processes in memory or more RAM (working-set model).

Symptom: CPU utilization drops as the OS admits MORE processes.

Page replacement algorithms?

When memory is full, choose a victim page. FIFO evicts the oldest, simple but suffers Belady's anomaly (more frames can mean MORE faults). LRU evicts the least recently used, approximating optimal. Optimal evicts the page used farthest in the future, impossible in practice but the benchmark.

Trap: Name the anomaly and who is immune: LRU and Optimal do not exhibit Belady's anomaly.

What is IPC?

Inter-process communication lets isolated processes exchange data. Main mechanisms: pipes (one-way, related processes), message queues, shared memory (fastest, needs synchronization), sockets (works across machines), and signals for simple notifications.

Trap: Which is fastest and why? Shared memory, because data is not copied through the kernel per message.

Multiprogramming vs multitasking vs multithreading?

Multiprogramming keeps several jobs in memory so the CPU always has work. Multitasking time-slices the CPU between them so they appear simultaneous. Multithreading splits one process into several threads that share its memory.

A browser is multithreaded: one thread renders while another downloads.

Kernel mode vs user mode?

The CPU has two privilege levels. User code cannot touch hardware or other processes directly; it must make a system call, which traps into kernel mode, runs the privileged operation, and returns. This protects the system from buggy or malicious programs.

read(), write(), fork() are system calls; a library call like printf wraps write().

Trap: Follow-up: what exactly happens on a syscall? Mode switch via trap, not a normal function call.

Go deeper

A recap is not practice. These are the creators we rate for real depth on operating systems; full credit to each.

One topic down. Keep the streak going.

Each recap takes 3 minutes; the full set covers everything the first round tests. And when the test is cleared, your resume takes the next screen.

Original content by OptiResume; facts and formulas are common knowledge, the wording is ours. Go-deeper links go to creators we rate; we are not affiliated with them.