Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Guides › Interviews

Top 50 Operating System Interview Questions (with Answers)

Processes and threads, CPU scheduling, synchronization, deadlocks, paging and virtual memory, file systems — 50 OS questions with short answers.

Operating systems questions test whether you understand what happens underneath your code: processes, threads, scheduling, memory and synchronization. These 50 questions are the ones freshers face most. Answers are short; the linked notes have diagrams, solved examples and code.

Basics

1. What is an operating system? Software that manages hardware and provides services to programs: process management, memory management, file systems, I/O and security.

2. Main functions of an OS? Process and CPU scheduling, memory management, file management, device/I/O management, security and protection, user interface.

3. What is a kernel? The core of the OS that runs in privileged mode and manages CPU, memory and devices.

4. Monolithic vs microkernel? Monolithic: all OS services in one big kernel (Linux) — fast, but a bug can crash everything. Microkernel: minimal kernel, services in user space — more reliable, more overhead.

5. User mode vs kernel mode? User programs run in restricted user mode; the kernel runs in kernel mode with full hardware access. A system call switches from one to the other.

6. What is a system call? A request from a program to the kernel — e.g. read, write, fork, open.

7. Types of OS? Batch, time-sharing (multitasking), real-time, distributed, embedded, mobile.

8. What is a real-time OS? An OS that guarantees responses within strict time limits — used in medical devices, cars, aircraft.

Processes and threads

9. What is a process? A program in execution, with its own memory (code, data, heap, stack). See Process vs Thread.

10. Process states? New, ready, running, waiting (blocked), terminated.

11. What is a PCB? The Process Control Block — the OS's record of a process: PID, state, program counter, registers, memory info, open files.

12. What is a thread? The smallest unit of execution inside a process; threads share the process's code, data and heap but have their own stack and registers.

13. Process vs thread? Processes have separate memory and are heavier to create and switch; threads share memory and are lighter, but one crashing thread can kill the process.

14. What is a context switch? Saving the state of the running process/thread and loading another's. It is pure overhead.

15. What does fork() do? Creates a child process as a copy of the parent. It returns 0 in the child and the child's PID in the parent. n fork() calls in sequence create 2ⁿ processes.

16. Zombie and orphan processes? Zombie: finished, but the parent hasn't collected its exit status. Orphan: the parent died first; init/systemd adopts it.

17. Ways of inter-process communication? Pipes, message queues, shared memory (fastest), sockets, signals.

18. Concurrency vs parallelism? Concurrency: handling many tasks by switching between them. Parallelism: running many tasks at the same instant on multiple cores.

CPU scheduling

19. What is CPU scheduling? Deciding which ready process gets the CPU next. See CPU Scheduling Algorithms.

20. Preemptive vs non-preemptive? Preemptive: the OS can take the CPU away (Round Robin, SRTF). Non-preemptive: a process runs until it finishes or blocks (FCFS, SJF).

21. Turnaround time and waiting time? TAT = completion time − arrival time. WT = TAT − burst time.

22. Which algorithm gives the minimum average waiting time? SJF among non-preemptive algorithms; SRTF (preemptive SJF) overall.

23. What is the convoy effect? In FCFS, short processes wait behind one long process.

24. What is starvation and aging? Starvation: a low-priority process never runs. Aging: gradually raising the priority of waiting processes.

25. How does Round Robin work, and how should the time quantum be chosen? Each process runs for one quantum then goes to the back of the queue. Too large → behaves like FCFS; too small → too many context switches.

26. Multilevel feedback queue? Several queues with different priorities; processes move between them based on behaviour (CPU-heavy ones sink, interactive ones stay high).

Synchronization

27. What is a race condition? The result depends on the timing of threads accessing shared data — e.g. two threads doing count++ at once.

28. What is the critical section problem? Ensuring only one process at a time runs the code that touches shared data, with mutual exclusion, progress and bounded waiting. See Process Synchronization.

29. Mutex vs semaphore? A mutex is a lock owned by one thread (lock/unlock). A semaphore is a counter (wait/signal) that can allow several threads, and isn't owned.

30. Binary vs counting semaphore? Binary: values 0/1 (like a mutex). Counting: any non-negative value — controls access to N identical resources.

31. Producer–consumer problem? Producers add to a bounded buffer and consumers remove; solved with semaphores empty, full and a mutex.

32. What is a monitor? A high-level construct where only one thread at a time can run its methods, with condition variables for waiting — Java's synchronized + wait/notify is monitor-like.

33. Busy waiting / spinlock? A thread loops checking a lock instead of sleeping. Fine for very short waits on multi-core systems; wasteful otherwise.

Deadlocks

34. What is a deadlock? A set of processes each waiting for a resource held by another, so none can proceed. See Deadlocks.

35. Four necessary conditions? Mutual exclusion, hold and wait, no preemption, circular wait — all four must hold.

36. How can deadlocks be prevented? Break one condition — most practically, circular wait, by always requesting resources in a fixed order.

37. What is the Banker's algorithm? A deadlock-avoidance algorithm that grants a request only if the system stays in a safe state (some order lets every process finish).

38. Deadlock vs starvation vs livelock? Deadlock: everyone waits forever. Starvation: one process never gets its turn. Livelock: processes keep changing state in response to each other but make no progress.

Memory management

39. Logical vs physical address? Logical addresses are generated by the program; the MMU translates them to physical RAM addresses. See Memory Management, Paging and Virtual Memory.

40. Internal vs external fragmentation? Internal: wasted space inside an allocated block. External: enough total free memory but split into unusable holes.

41. What is paging? Splitting logical memory into fixed-size pages and physical memory into frames, so any page fits any frame — removes external fragmentation.

42. What is a TLB? A small, fast cache of recent page-to-frame translations that avoids reading the page table on every access.

43. Paging vs segmentation? Paging uses fixed-size, invisible pages. Segmentation uses variable-size logical segments (code, stack, heap) visible to the programmer.

44. What is virtual memory? Running programs larger than RAM by keeping only needed pages in memory and the rest on disk.

45. What is a page fault? Accessing a page not currently in RAM — the OS loads it from disk and restarts the instruction.

46. Page replacement algorithms? FIFO, LRU, Optimal (theoretical best), LFU, Clock. See Page Replacement Algorithms.

47. What is Belady's anomaly? With FIFO, giving a process more frames can cause more page faults.

48. What is thrashing? The system spends most of its time swapping pages instead of doing work, because processes don't have enough frames.

Files and disks

49. File allocation methods? Contiguous (fast, but fragmentation), linked (no fragmentation, slow random access), indexed (an index block per file). See File Systems and Disk Scheduling.

50. Disk scheduling algorithms? FCFS, SSTF (shortest seek first), SCAN (elevator), C-SCAN, LOOK — they reduce the disk head's movement.

Practise

More guides