Operating Systems · Lesson 9 of 9 · Updated ·
Top Operating System Interview Questions — With Short Answers
Revise these before technical rounds. Each answer fits in two lines — expand with an example if asked.
Basics
- What is an OS? Software that manages hardware and provides services to programs: processes, memory, files, devices, security.
- Kernel? The core of the OS running in privileged kernel mode.
- System call? The way a program requests an OS service (e.g.
read,fork). - Monolithic vs microkernel? Monolithic: all services in the kernel (fast, Linux). Microkernel: minimal kernel, services in user space (stable, modular).
Processes and threads
- Program vs process? A program is a passive file; a process is a program in execution.
- Process vs thread? Processes have separate memory; threads share their process's memory and have their own stacks.
- What is a PCB? The Process Control Block — the OS's record of a process (PID, state, registers, memory info).
- Context switch? Saving one process's CPU state and loading another's; pure overhead.
- Zombie vs orphan? Zombie: finished but not yet reaped by its parent. Orphan: parent died; adopted by init.
Scheduling
- Preemptive vs non-preemptive? Preemptive can interrupt a running process; non-preemptive lets it finish its burst.
- Which scheduling minimises average waiting time? SJF (non-preemptive) / SRTF (preemptive).
- Convoy effect? In FCFS, short jobs wait behind a long one.
- Starvation and aging? Starvation: a process waits indefinitely. Aging: gradually raising its priority.
Synchronization and deadlock
- Race condition? The output depends on the timing of concurrent access to shared data.
- Mutex vs semaphore? Mutex: a lock with an owner. Semaphore: a counter with wait/signal; can manage n resources.
- Deadlock conditions? Mutual exclusion, hold and wait, no preemption, circular wait — all four.
- Deadlock vs starvation? Deadlock: processes wait for each other forever. Starvation: one process waits while others progress.
- Banker's algorithm? Deadlock avoidance — grant a request only if the system stays in a safe state.
Memory
- Paging vs segmentation? Paging: fixed-size pages (no external fragmentation). Segmentation: variable-size logical segments.
- Internal vs external fragmentation? Internal: waste inside an allocated block. External: free memory split into unusable holes.
- What is a TLB? A fast cache of page-table entries that speeds up address translation.
- Virtual memory? Using disk to extend RAM; only needed pages stay in memory (demand paging).
- Page fault? Accessing a page that isn't in RAM; the OS loads it from disk.
- Thrashing? Excessive paging that leaves the CPU idle; fix by reducing multiprogramming or adding frames.
- Belady's anomaly? With FIFO replacement, more frames can cause more page faults.
Bonus: quick calculations interviewers like
- n calls to fork() → 2ⁿ processes in total.
- Page number / offset: page = address ÷ page size, offset = address mod page size.
- Waiting time = turnaround − burst; turnaround = completion − arrival.
Common mistakes
- Mixing up deadlock prevention (break a condition) and avoidance (stay safe).
- Saying threads have separate heaps.
- Forgetting that all four deadlock conditions are needed together.
Quick recap
- Revise: kernel, process vs thread, PCB, scheduling, race conditions, mutex vs semaphore, deadlock, paging, virtual memory, thrashing.
- Answer in two lines, then give an example.