Operating Systems Interview Questions with Worked Answers
Last updated 2026-11-19
Operating systems is one of the four core subjects (with DBMS, networks and OOPS) that campus interviews and technical MCQ rounds keep returning to. Interviewers rarely ask for textbook definitions alone. They ask you to compare two ideas, trace a small program, or compute a number. This page covers the broad questions that open an OS discussion, and each deeper area has its own page linked below.
Every answer here is written the way you would say it aloud in two minutes: a crisp definition, one reason it matters, and a small example. For the round structure and preparation plan, read how to crack an operating systems interview. For the wider picture, see how to crack a technical interview.
| Subtopic pages | CPU scheduling, deadlock, memory, paging, synchronization, processes, file systems |
|---|---|
| Numericals here | Effective access time with a TLB, bit counts for addresses |
| Questions | 16, easy to hard |
How to use this page
Start with the definitions and comparisons (questions 1 to 9), then work the two numericals with pen and paper before reading the working. Once the overview feels solid, move to the depth pages: CPU scheduling for Gantt charts, deadlock for the Banker's algorithm, and paging and virtual memory for page-fault counts.
Mistakes that cost marks
- Saying a process and a program are the same thing. A program is a file on disk; a process is that program in execution with its own address space and state.
- Mixing up a mutex and a semaphore, or a trap and an interrupt. Be ready to give one line that separates each pair.
- Quoting a formula without units. In effective access time questions, convert everything to nanoseconds first.
Operating Systems Interview Questions with Worked Answers: questions with worked answers
1 What is an operating system and what are its main functions?
easyAn operating system is system software that manages the hardware and gives applications a stable interface to use it. Its main functions are process management (creating, scheduling and terminating processes), memory management, file system management, device management through drivers, protection and security, and providing a user interface such as a shell or GUI. Examples are Linux, Windows and Android.
2 What is the difference between kernel mode and user mode?
easyThe CPU has a mode bit. In kernel mode the code can execute privileged instructions and touch any memory or device. In user mode the code is restricted, so a faulty application cannot crash the whole machine. An application moves to kernel mode only through a controlled entry such as a system call, an interrupt or a trap, and the CPU switches back to user mode when the kernel returns.
3 What is a system call? Give examples.
easyA system call is the controlled way a user program asks the kernel to do something privileged. Typical groups are process control (fork, exec, exit, wait), file operations (open, read, write, close), device control (ioctl) and information (getpid, time). A library function like printf eventually calls the write system call. The call triggers a software interrupt or a special instruction (syscall), the CPU enters kernel mode, runs the handler and returns the result.
4 Differentiate between a process and a thread.
easyA process has its own address space, open files and resources, so processes are isolated and heavier to create. Threads inside one process share code, data, heap and open files but each has its own stack, program counter and registers. Switching between threads is cheaper because there is no change of address space, but a bug in one thread can corrupt data seen by all the others. See processes and threads for more.
5 What is a context switch and why is it considered overhead?
mediumA context switch saves the state of the running process (registers, program counter, stack pointer, memory-management data) into its process control block and loads the saved state of another one. The CPU does no useful work for the user during the switch, and the cache and TLB contents of the old process become less useful for the new one. That is why scheduling with a very small time quantum wastes time: the switch cost becomes large compared with the work done.
6 Compare monolithic kernels and microkernels.
mediumIn a monolithic kernel (Linux, classic Unix) the scheduler, memory manager, file systems and drivers all run in kernel space, so calls between them are fast function calls, but one buggy driver can crash the system. A microkernel keeps only the minimum (address spaces, IPC, basic scheduling) in the kernel and runs drivers and file systems as user-space servers. This is safer and easier to extend, but message passing between servers is slower. Windows NT and macOS use hybrid designs.
7 What is the difference between an interrupt and a trap?
easyAn interrupt is asynchronous: it is raised by hardware (a keyboard press, a timer tick, a disk finishing a transfer) at any time, unrelated to the instruction being executed. A trap, also called an exception, is synchronous: the running instruction causes it, for example divide by zero, an invalid memory access or a deliberate system call. In both cases the CPU saves state and jumps to a handler found through the interrupt vector table.
8 What is a process control block (PCB)? What does it contain?
mediumThe PCB is the kernel data structure that represents a process. It stores the process ID, process state (new, ready, running, waiting, terminated), program counter, saved CPU registers, scheduling information such as priority, memory-management information (page table pointer, limits), accounting data and the list of open files or I/O devices. The scheduler moves PCBs between the ready queue and device queues.
9 What is the difference between a zombie process and an orphan process?
mediumA zombie has finished executing but still has an entry in the process table because its parent has not yet called wait() to read its exit status. It uses no CPU or memory except that entry. An orphan is a process that is still running after its parent has terminated; on Linux it is adopted by init (PID 1) or systemd, which reaps it when it finishes.
10 Differentiate between paging and segmentation.
mediumPaging divides logical memory into fixed-size pages and physical memory into frames of the same size, so it has no external fragmentation, only internal fragmentation in the last page. It is invisible to the programmer. Segmentation divides memory into variable-size logical units such as code, stack and heap, matching how the programmer sees the program, but it suffers from external fragmentation. Many systems combine them. See memory management.
11 What is virtual memory and why is it useful?
mediumVirtual memory gives each process the illusion of a large, private, contiguous address space, while the OS keeps only the pages currently needed in RAM and the rest on disk. It lets programs larger than physical memory run, allows more processes to be resident, isolates processes from each other and simplifies loading. The cost is page faults: a reference to a page not in RAM costs milliseconds, so locality of reference is what makes it work.
12 State the four necessary conditions for deadlock.
mediumMutual exclusion (a resource is held by one process at a time), hold and wait (a process holds some resources while waiting for others), no preemption (resources cannot be forcibly taken) and circular wait (a cycle of processes each waiting for a resource held by the next). All four must hold together. Breaking any one prevents deadlock; imposing a global ordering on resource requests breaks circular wait. Details are on the deadlock page.
13 What is a race condition? How do you prevent it?
mediumA race condition occurs when the result depends on the unpredictable order in which threads or processes access shared data. For example two threads executing counter++ each do load, add, store, and both may load the same old value so one update is lost. Prevent it by making the critical section atomic with a mutex, semaphore, monitor or an atomic instruction, and by minimising shared mutable state. See process synchronization.
14 Numerical: Memory access takes 100 ns and a TLB lookup takes 20 ns. The TLB hit ratio is 80%. Find the effective memory access time with a single-level page table.
mediumOn a TLB hit the cost is one TLB lookup plus one memory access to fetch the data: 20 + 100 = 120 ns. On a miss the cost is the TLB lookup, one memory access to read the page table entry and one more to fetch the data: 20 + 100 + 100 = 220 ns. Effective access time = 0.8 x 120 + 0.2 x 220 = 96 + 44 = 140 ns. Without the TLB every access would cost 200 ns, so the TLB saves 30 percent.
15 Numerical: A system has a 32-bit logical address and 4 KB pages. How many bits are the page number and offset, and how many page-table entries are needed?
medium4 KB = 2^12 bytes, so the offset is 12 bits. The page number is the remaining 32 - 12 = 20 bits. A single-level page table therefore has 2^20 = 1,048,576 entries. With 4-byte entries the table alone takes 4 MB per process, which is why multi-level page tables are used.
16 What happens, step by step, from pressing the power button until a shell prompt appears on Linux?
hardThe firmware (BIOS or UEFI) runs the power-on self test, then finds a boot device and loads the bootloader (GRUB). The bootloader loads the kernel image and an initial RAM disk into memory and passes control to the kernel. The kernel initialises memory management, the scheduler and drivers, mounts the root file system and starts the first user process, PID 1 (systemd on most distributions). systemd starts services according to the default target, and finally a login process or display manager gives you a shell or desktop.
17 Why can a larger time quantum or a larger page size both be a double-edged choice?
hardBoth trade one overhead for another. A larger quantum cuts context-switch overhead but makes round robin behave like FCFS and hurts response time. A larger page size shrinks the page table and improves disk transfer efficiency, but wastes more memory as internal fragmentation (on average half a page per region) and may load data that is never used. Good answers name both sides and say that the best value comes from measuring the workload.
Frequently asked questions
Which operating systems topics are asked most in interviews?
Process versus thread, scheduling algorithms with Gantt charts, deadlock and the Banker's algorithm, paging and page replacement, synchronization with semaphores, and virtual memory are the most common. Linux commands and the boot process also appear for DevOps and system roles.
Do I need to know C for operating systems questions?
Reading short C snippets helps, especially fork() programs and semaphore pseudocode. You do not need to write kernel code. Be comfortable predicting the output of a program that calls fork a few times.
How long should I take to prepare operating systems?
For a fresher with a semester of coursework, about a week of focused revision covers the subject: two days on processes and scheduling, one each on synchronization and deadlock, two on memory and paging, one on files and I/O. Solve numericals rather than only reading.
What is the difference between multiprogramming, multitasking and multiprocessing?
Multiprogramming keeps several programs in memory so the CPU switches when one waits for I/O. Multitasking adds time slicing so each gets the CPU in turn and users see them run together. Multiprocessing uses more than one CPU or core to run tasks truly in parallel.
Related guides
- CPU Scheduling Interview Questions with Gantt Chart Numericals
- Deadlock Interview Questions with Banker's Algorithm Worked Example
- Memory Management Interview Questions with Numericals
- Paging and Virtual Memory Interview Questions with Numericals
- Process Synchronization Interview Questions: Semaphores, Mutex and Classic Problems
- Process and Thread Interview Questions with fork() Output Problems
- Linux Interview Questions and Answers: Concepts, Permissions and Processes
- Computer Networks Interview Questions with Worked Answers and Numericals
More in CS Fundamentals Interview Questions
- OSI Model Interview Questions: Layers, PDUs, Devices and Encapsulation
- Paging and Virtual Memory Interview Questions with Numericals
- Process and Thread Interview Questions with fork() Output Problems
- Process Synchronization Interview Questions: Semaphores, Mutex and Classic Problems
- Redis Interview Questions and Answers
- REST API Interview Questions and Answers
- Routing Protocols Interview Questions: RIP, OSPF, BGP and Shortest Path Examples
- SDLC and Agile Interview Questions
- Shell Scripting Interview Questions with Bash Examples
- SOLID Principles Interview Questions with Examples
- System Design Interview Questions for Freshers
- System Design Interview Questions with Worked Designs