Practice
Solution
Step 1: Identify synchronization needs
Producers must wait if the buffer is full; consumers must wait if empty. This requires tracking counts of empty and full slots.Step 2: Role of counting semaphores
Counting semaphores elegantly track available slots (empty) and filled slots (full), enabling blocking waits without busy-waiting.Step 3: Need for mutual exclusion
A mutex is required to protect concurrent access to the buffer itself to avoid race conditions.Step 4: Why other options fail
Mutex alone (A) cannot block producers/consumers based on buffer state; spinlocks (C) waste CPU cycles; condition variables (D) require mutexes and signaling to work correctly in this scenario.Final Answer:
Option C -> Option CQuick Check:
Counting semaphores + mutex is the classic producer-consumer solution [OK]
- Assuming mutex alone handles waiting
- Using spinlocks wastes CPU
- Thinking condition variables alone suffice
Solution
Step 1: Understand preemptive SJF behavior
Preemptive SJF allows the CPU to switch to a newly arrived process if it has a shorter burst time than the currently running process.Step 2: Analyze scenarios
If new processes with shorter burst times can arrive anytime, preemptive SJF ensures the CPU always runs the shortest job next, improving average waiting time.Step 3: Why other options are incorrect
A: If all processes arrive simultaneously with similar burst times, preemptive advantage is minimal.
B: Starvation is a concern in preemptive SJF, so it's not chosen when fairness is ignored.
C: Preemptive SJF increases context switches, so it's not preferred when minimizing overhead.Final Answer:
Option A -> Option AQuick Check:
Preemptive SJF is best when shorter jobs can arrive anytime, requiring immediate preemption.
- Assuming preemptive SJF always reduces overhead
- Believing preemptive SJF is best when all jobs arrive simultaneously
Solution
Step 1: Understand deadlock conditions
Deadlock occurs when each process holds a resource and waits for the other, causing indefinite blocking.Step 2: Analyze the immediate aftermath
Neither process releases resources voluntarily, so both remain blocked indefinitely (both processes remain blocked indefinitely, waiting for the other to release the resource). Both processes releasing their held resources and retrying immediately is incorrect because processes do not release resources spontaneously. The operating system preempting one process to break the deadlock automatically is incorrect as OS preemption is not automatic in typical deadlock. Both processes entering a livelock, continuously retrying without progress describes livelock, which involves active state changes, not blocking.Final Answer:
Option A -> Option AQuick Check:
Deadlock means indefinite waiting without resource release, matching both processes remain blocked indefinitely, waiting for the other to release the resource.
- Assuming OS automatically resolves deadlock
- Confusing deadlock with livelock
Solution
Step 1: Identify TLB miss consequence
A TLB miss means the translation is not cached, so the system must look up the page table.Step 2: Follow the steps
On a miss, the page table is consulted to get the physical frame number.
The TLB is updated with this translation for future accesses.
Then the memory access proceeds using the physical address.Step 3: Analyze incorrect options
A: Page fault only occurs if the page is not in memory, not on every TLB miss.
B: TLB does not fetch from disk; page table lookup is in memory.
C: CPU does not retry blindly; it performs page table lookup.Final Answer:
Option A -> Option AQuick Check:
TLB miss triggers page table lookup and TLB update before memory access.
- Confusing TLB miss with page fault
- Thinking TLB fetches translations from disk
Solution
Step 1: Identify internal fragmentation cause
Buddy system rounds allocations to power-of-two sizes, causing internal fragmentation.Step 2: Evaluate strategies
Slab allocator efficiently manages fixed-size objects, reducing internal fragmentation without slowing allocation.Step 3: Analyze other options
Increasing minimum block size (A) increases internal fragmentation; compaction (C) addresses external fragmentation; fixed partitioning (D) is inflexible and can worsen fragmentation.Final Answer:
Option C -> Option CQuick Check:
Slab allocators complement buddy system to reduce internal fragmentation [OK]
- Thinking compaction reduces internal fragmentation
- Assuming bigger minimum block size reduces fragmentation
- Believing fixed partitioning eliminates fragmentation
