💻
Free Study Guide · 2025
Top 10 Operating SystemInterview Questions & Answers (2025)
Operating Systems is one of the most commonly tested CS fundamentals in campus placements at TCS, Infosys, Amazon, Microsoft, and every company that does core technical rounds. These 30 questions cover processes, scheduling, deadlock, memory management, and synchronization — exactly what interviewers ask.
✓ 10 questions
✓ Detailed answers
✓ 100% free
1What is an Operating System? What are its main functions?▼
An OS is system software that acts as an interface between hardware and user applications. Main functions: Process Management (create, schedule, terminate processes), Memory Management (allocate/deallocate RAM), File System Management (organize files on disk), I/O Management (manage device drivers), Security & Access Control, and providing a User Interface (CLI/GUI). Without an OS, each application would need to directly manage hardware — impractical and insecure.
2What is the difference between a process and a thread?▼
A process is an independent program in execution with its own memory space (code, data, heap, stack). Threads are lightweight units of execution within a process — they share the same memory space (code, data, heap) but each has its own stack and registers. Creating a thread is much cheaper than creating a process. Context switching between threads is faster. Processes are isolated; a crash in one doesn't affect another. Threads within a process can corrupt shared memory if not synchronized properly.
3What is CPU scheduling? What are the main scheduling algorithms?▼
CPU scheduling decides which process gets the CPU when multiple processes are ready. Key algorithms: FCFS (First Come First Served) — simple but poor for short jobs behind long ones. SJF (Shortest Job First) — optimal average wait time but requires knowing burst time in advance. Round Robin — each process gets a fixed time quantum, cycled repeatedly — best for time-sharing. Priority Scheduling — highest priority runs first, can cause starvation (fixed with aging). Multilevel Queue — separate queues for different process types (interactive vs batch).
4What is a deadlock? What are the four necessary conditions?▼
A deadlock is a situation where a set of processes are all waiting for resources held by each other — none can proceed. The four Coffman conditions (all must hold simultaneously): 1. Mutual Exclusion — at least one resource is non-shareable. 2. Hold and Wait — a process holds resources while waiting for more. 3. No Preemption — resources cannot be forcibly taken from a process. 4. Circular Wait — a circular chain of processes each waiting for a resource held by the next. Deadlock prevention removes at least one condition; deadlock avoidance uses algorithms like Banker's Algorithm.
5What is virtual memory? How does it work?▼
Virtual memory creates an illusion that each process has its own large, contiguous address space, even if physical RAM is limited. It works by mapping virtual addresses to physical RAM pages using a page table maintained by the OS and Memory Management Unit (MMU). Pages not currently in RAM are stored on disk (swap space). When a process accesses a page not in RAM, a page fault occurs and the OS loads the page from disk. This allows running programs larger than physical RAM but disk access causes latency.
6What is paging? How does it differ from segmentation?▼
Paging divides physical memory into fixed-size frames and virtual memory into equal-size pages. The page table maps virtual page numbers to physical frame numbers. It eliminates external fragmentation (frames are fixed-size) but causes internal fragmentation (last page may not be full). Segmentation divides memory into variable-size logical units (code, stack, heap segments) based on program structure. It has no internal fragmentation but suffers external fragmentation. Modern OS (x86-64) use paged segmentation — segmentation on top of paging.
7What is a page fault? What happens when one occurs?▼
A page fault occurs when a process accesses a virtual page not currently loaded in physical RAM. Steps: 1. MMU detects the missing page and raises a page fault interrupt. 2. OS takes control, checks if the access is valid (if not → segfault). 3. OS finds a free frame (or evicts a page using a replacement algorithm like LRU). 4. OS reads the required page from disk into the frame. 5. OS updates the page table. 6. Process resumes at the faulting instruction. Frequent page faults (thrashing) kill performance.
8What is thrashing?▼
Thrashing occurs when a system spends more time swapping pages in and out of memory than executing actual processes. It happens when the total working set of all running processes exceeds available physical RAM — each process page-faults constantly, causing the OS to continuously swap, leaving no CPU time for real work. Solutions: reduce multiprogramming degree (run fewer processes), increase RAM, improve page replacement algorithm, or use working set model to track how many pages each process actually needs.
9What is a semaphore? How does it differ from a mutex?▼
A semaphore is a synchronization primitive that controls access to shared resources. It maintains a counter: wait() (P) decrements it; signal() (V) increments it. Binary semaphore (0 or 1) — works like a mutex. Counting semaphore — allows N processes into a critical section simultaneously. Mutex (Mutual Exclusion Lock): a locking mechanism where only the thread that locked it can unlock it — it has ownership. A binary semaphore has no ownership — any thread can signal it. Use mutex for mutual exclusion; use semaphore for signaling between threads or resource counting.
10What is a critical section? What are Peterson's Solution conditions?▼
A critical section is a code segment that accesses shared resources and must not be executed by more than one process simultaneously. Requirements for a correct critical section solution: 1. Mutual Exclusion — only one process inside at a time. 2. Progress — if no process is in the critical section, a waiting process should be able to enter without indefinite delay. 3. Bounded Waiting — a process must not wait forever (bounded number of times others can enter before it). Peterson's Solution uses two variables (flag and turn) to satisfy all three for two processes — not used in practice (hardware solutions preferred).
Level up your prep
Get company-specific Operating System questions
Upload your resume → get questions tailored to Google, Amazon, TCS, and 50+ companies.