Operating systems MCQs with answers and explanations
Revise processes, scheduling, deadlocks, synchronisation and memory management. Use operating-system concept notes and explained questions for technical placements, interviews and GATE CS preparation.
Operating Systems (OS) are system software that manages computer hardware and software resources, providing common services for computer programs. Core topics include process management, memory management, file systems, I/O management, and CPU scheduling. Understanding these concepts is essential for system programming, performance optimisation, and technical interviews.
Key formulas and rules
10 rulesCPU Utilization:
Turnaround Time (TAT):
Waiting Time (WT):
Response Time (RT):
Throughput:
Page Fault Rate:
Effective Memory Access Time (EMAT):
Disk Access Time:
Rotational Latency:
Banker's Algorithm Safety: A state is safe if there exists a sequence such that for each process , , where and (accumulating released allocations as earlier processes finish)
Key concepts
Process vs Thread
A process is an independent program in execution with its own address space, resources, and PCB (Process Control Block). A thread is a lightweight unit of execution within a process, sharing the same address space and resources but having its own stack, registers, and program counter. Processes are isolated; threads within the same process communicate easily but can cause race conditions. Context switching between threads is faster than between processes.
CPU Scheduling Algorithms
First-Come-First-Served (FCFS): Non-preemptive, simple, may cause convoy effect. Shortest Job First (SJF): Optimal for minimum waiting time, requires prediction of burst times. Priority Scheduling: Can be preemptive or non-preemptive, may suffer from starvation. Round Robin (RR): Time quantum-based, fair, good for time-sharing systems. Multilevel Queue: Processes permanently assigned to queues. Multilevel Feedback Queue: Allows processes to move between queues based on behaviour.
Memory Management
Contiguous Allocation: Memory divided into partitions (fixed or variable size). External fragmentation occurs in variable partitioning. Paging: Divides logical memory into fixed-size pages and physical memory into frames. Eliminates external fragmentation, may have internal fragmentation. Segmentation: Divides memory into variable-sized segments based on program structure (code, data, stack). Virtual Memory: Allows execution of processes not entirely in memory using demand paging. Page replacement algorithms: FIFO, Optimal, LRU, LRU Approximation (Clock), Second Chance.
Deadlock
Deadlock occurs when processes wait indefinitely for resources held by each other. Four necessary conditions: Mutual Exclusion (resources cannot be shared), Hold and Wait (process holds resources while waiting for more), No Preemption (resources cannot be forcibly taken), Circular Wait (circular chain of processes waiting). Deadlock Handling: Prevention (break one condition), Avoidance (Banker's Algorithm), Detection and Recovery, Ignorance (Ostrich Algorithm). Banker's Algorithm checks if system is in safe state before granting resource requests.
Synchronisation Mechanisms
Race Condition: Multiple processes access shared data concurrently with outcome dependent on execution order. Critical Section: Code segment accessing shared resources; requires mutual exclusion. Solutions: Peterson's Solution (software), Mutex Locks (binary semaphore), Semaphores (counting and binary), Monitors (high-level abstraction). Classical Problems: Producer-Consumer (Bounded Buffer), Readers-Writers, Dining Philosophers. Deadlock can occur in Dining Philosophers if all pick up left fork simultaneously.
File System & I/O
File Allocation Methods: Contiguous (fast access, external fragmentation), Linked (no fragmentation, slow random access), Indexed (direct access, pointer overhead). Directory Structure: Single-level, Two-level, Tree-structured, Acyclic Graph (shared files), General Graph (allows cycles, requires garbage collection). Disk Scheduling: FCFS, SSTF (shortest seek time first), SCAN (elevator), C-SCAN, LOOK, C-LOOK. I/O Techniques: Programmed I/O, Interrupt-Driven I/O, DMA (Direct Memory Access) for large transfers without CPU intervention.
Worked examples
Example 1
Three processes arrive at time 0 with burst times: , , . Compare the average waiting times under FCFS and SJF scheduling.
Solution
Step 1: FCFS (order ).
- Waiting times: , ,
Step 2: SJF (order ).
- Waiting times: , ,
Answer: FCFS average waiting time is 17 ms; SJF reduces it to 3 ms.
Example 2
A demand paging virtual memory system has memory access time and page fault service time . If the page fault rate is , calculate the Effective Access Time (EAT).
Solution
Step 1: Apply the EAT formula.
Step 2: Substitute values.
Answer: (or ).
Example 3
In a paging system with TLB, TLB lookup time is 20 ns and main memory access time is 100 ns. If the TLB hit ratio is 90%, what is the effective memory access time?
Solution
Step 1: Formulate TLB EAT equation.
Step 2: Substitute parameters.
- On TLB hit:
- On TLB miss:
Answer: 130 ns.
Example 4
Explain the four necessary Coffman conditions for deadlock in operating systems.
Solution
Step 1: Mutual Exclusion.
At least one resource must be held in a non-shareable mode (only one process can use it at a time).
Step 2: Hold and Wait.
A process holding at least one allocated resource is waiting to acquire additional resources held by other processes.
Step 3: No Preemption.
Resources cannot be forcibly confiscated from a process; they can only be released voluntarily after completing its task.
Step 4: Circular Wait.
A closed chain of processes exists such that waits for a resource held by , waits for , and waits for .
Answer: Deadlock can occur only if all four conditions hold simultaneously.
Representative solved questions
See the kind of question in this topic before opening the full practice set.
Question 1
Using the SCAN (Elevator) disk scheduling algorithm, the disk arm starts at track 100 and moves towards track 0. Requests are at tracks: 95, 180, 34, 119, 11, 123, 62, 64. What is the total head movement?
Answer: C. 280 tracks
ExplanationStep 1: In the SCAN algorithm, the disk arm moves in the initial direction towards track 0, servicing all requests along the path (95, 64, 62, 34, 11) until reaching the end track 0.
Step 2: Head movement going down: |100 - 0| = 100 tracks.
Step 3: At track 0, the arm reverses direction and moves upward, servicing remaining requests (119, 123, 180) up to the farthest request at track 180.
Step 4: Head movement going up: |180 - 0| = 180 tracks.
Step 5: Total head movement = 100 + 180 = 280 tracks.
Answer: 280 tracks
Sources and review notes
This is an AISEA-authored practice question.
Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening
Question 2
Which scheduling algorithm may minimise average waiting time but can lead to starvation?
Answer: D. Shortest Job First
ExplanationShortest Job First often reduces average waiting time, but long jobs may starve if shorter jobs continue to arrive.
Sources and review notes
This is an AISEA-authored practice question.
Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening
Question 3
What is the maximum file size in a file system using inodes with 12 direct pointers, 1 single indirect, 1 double indirect, and 1 triple indirect, with 4KB blocks and 4-byte addresses?
Answer: B. Approximately 4 TB
ExplanationStep 1: Block size = 4KB, pointer size = 4 bytes.
Step 2: Pointers per block = 4096 / 4 = 1024 pointers.
Step 3: Direct: 12 x .
Step 4: Single indirect: 1024 x .
Step 5: Double indirect: 1024 x 1024 x .
Step 6: Triple indirect: 1024 x 1024 x 1024 x .
Step 7: Total ~= 4TB + 4GB + 4MB + 48KB ~= 4TB.
Step 8: This is the Unix inode structure used in ext2/ext3.
Answer: Approximately 4 TB
Sources and review notes
This is an AISEA-authored practice question.
Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening
Common mistakes and useful habits
- For CPU scheduling problems, always draw a Gantt chart to visualise process execution order and calculate completion times accurately.
- Remember the key differences: Paging uses fixed-size blocks (eliminates external fragmentation), Segmentation uses variable-size blocks (matches program structure).
- In deadlock questions, check for ALL four necessary conditions. Breaking any one condition prevents deadlock.
- For page replacement algorithms, track frames visually. LRU approximates Optimal; FIFO suffers from Belady's anomaly.
- Banker's Algorithm: Always calculate 'Need' matrix first, then find a process that can execute with current Available resources.
- For disk scheduling, SCAN (elevator) and C-SCAN provide more uniform wait times than SSTF which may cause starvation.
Ready to test your understanding?
Work through 235 questions with explanations after each answer.