Answers Latest Update 100% Correct 2025
Topic Coverage
• Processes & Threads
• CPU Scheduling
• Synchronization
• Memory Management
• Virtual Memory
• File Systems
• I/O & Storage
• Deadlock
• OS Architecture
• Distributed Systems (Intro)
Each question has:
✔ Correct answer
✔ Detailed rationale
Multiple Choice Questions
1.
The main difference between a process and a thread is that:
A. Threads have their own address space
,B. Processes share the same heap
C. Threads share a common address space within a process
D. Processes run faster than threads
Answer: C
Rationale:
A process has its own address space, file descriptors, stack, heap, and code
segment.
A thread exists inside a process and shares the same memory (code, data, heap)
with other threads, but has its own program counter and stack.
Therefore, threads allow lightweight concurrency with minimal context switching
overhead.
2.
Context switching involves:
A. Switching the CPU between kernel and user mode only
B. Saving and restoring the state of a CPU when switching threads or processes
C. Copying memory between processes
D. Restarting I/O operations
Answer: B
Rationale:
Context switching stores the CPU registers, program counter, stack pointer, and
other process metadata into a Process Control Block (PCB) and loads the next
process’s state.
It’s expensive because it may change address space, cache state, and kernel data
structures.
3.
Which CPU scheduling algorithm can suffer from starvation?
A. First-Come, First-Served (FCFS)
,B. Shortest Job First (SJF)
C. Round Robin (RR)
D. Multi-level Feedback Queue (MLFQ)
Answer: B
Rationale:
SJF always runs the shortest job available. If short jobs keep arriving, long jobs
may never run, which is starvation.
RR and MLFQ use preemption and time sharing, reducing starvation risk.
4.
In OS synchronization, a race condition occurs when:
A. Two processes use the same algorithm
B. The output depends on the timing of thread execution
C. One process finishes earlier than another
D. The CPU has too many processes
Answer: B
Rationale:
Race conditions happen when two threads access shared data simultaneously
without proper synchronization, and the final output depends on execution
order, which is nondeterministic.
5.
The critical section problem is solved by:
A. Caching
B. Mutual exclusion
C. Pipelining
D. Interrupts only
Answer: B
Rationale:
, Critical section = code that accesses shared data.
To prevent race conditions, we need mutual exclusion (mutex), ensuring only one
thread accesses the critical section at a time.
6.
A semaphore initialized to 1 acts like a:
A. Barrier
B. Spinlock
C. Mutex
D. Queue
Answer: C
Rationale:
Semaphore(1) = binary semaphore, functioning like a mutex.
Semaphore > 1 = counting semaphore.
7.
A deadlock requires which four conditions?
A. Sharing, paging, interrupts, I/O
B. Mutual exclusion, hold & wait, no preemption, circular wait
C. Cache hit, page fault, scheduling, blocking
D. Context switching, interrupts, starvation, paging
Answer: B
Rationale:
Deadlock occurs only if all four conditions exist simultaneously (Coffman
conditions):
1. Mutual exclusion
2. Hold and wait
3. No preemption