Practice
Solution
Step 1: Understand semaphore roles
'empty' counts available buffer slots; 'full' counts filled slots; mutex protects buffer access.Step 2: Producer must wait for empty slot
Producer waits (P operation) on 'empty' to ensure space is available before producing.Step 3: Acquire mutex before modifying buffer
Mutex wait ensures exclusive access to buffer.Step 4: Add item, then release mutex
After adding, signal (V operation) mutex to release critical section.Step 5: Signal 'full' to indicate new item
Signaling 'full' wakes consumers waiting for items.Step 6: Why other options fail
Wait on 'full' semaphore, wait on mutex, add item, signal mutex, signal 'empty' semaphore waits on 'full' which is incorrect; Wait on mutex, wait on 'empty' semaphore, add item, signal 'full' semaphore, signal mutex waits on mutex before 'empty' which can cause deadlock; Signal 'empty' semaphore, wait on mutex, add item, signal 'full' semaphore, wait on 'full' semaphore signals before waiting, breaking synchronization.Final Answer:
Option A -> Option AQuick Check:
Wait empty -> wait mutex -> produce -> signal mutex -> signal full [OK]
- Confusing 'full' and 'empty' semaphore roles
- Incorrect order of mutex and semaphore waits
- Signaling before waiting causing race
Solution
Step 1: Understand mutual exclusion
It requires that some resources be non-shareable, meaning only one process can use them at a time.Step 2: Analyze why eliminating mutual exclusion for all resources is impractical
Eliminating mutual exclusion for all resources is impossible because some resources (like printers) inherently cannot be shared.Step 3: Evaluate other options
Mutual exclusion means that at least one resource must be held in a non-shareable mode correctly defines mutual exclusion. Mutual exclusion is necessary for deadlock but not sufficient alone correctly states it is necessary but not sufficient. Mutual exclusion applies only to resources that cannot be simultaneously used by multiple processes correctly limits mutual exclusion to non-shareable resources.Final Answer:
Option B -> Option BQuick Check:
Mutual exclusion cannot be eliminated for all resources; some must be exclusive.
- Thinking mutual exclusion can be removed entirely
- Confusing necessity with sufficiency
- Misapplying mutual exclusion to shareable resources
Solution
Step 1: Analyze each statement
Imposing a strict ordering on resource acquisition always prevents deadlock is correct: ordering resources prevents circular wait; Allowing a philosopher to pick up both forks only if both are available prevents deadlock is correct: atomic acquisition avoids partial hold; Breaking one of the four Coffman conditions is sufficient to prevent deadlock is correct: breaking any Coffman condition prevents deadlock.Step 2: Evaluate Using asymmetric fork picking (odd philosophers pick left first, even pick right first) guarantees no starvation
Asymmetric fork picking prevents deadlock but does not guarantee no starvation, as some philosophers may be repeatedly delayed.Final Answer:
Option A -> Option AQuick Check:
Only Using asymmetric fork picking (odd philosophers pick left first, even pick right first) guarantees no starvation incorrectly claims starvation is guaranteed prevented.
- Assuming deadlock prevention implies starvation freedom
- Believing asymmetric picking solves all synchronization issues
- Confusing Coffman conditions with starvation conditions
Solution
Step 1: Analyze LRU Implementation Complexity
LRU needs to track the order of page usage, which is costly without hardware or data structures.Step 2: Evaluate Each Option
LRU requires hardware support or additional data structures to track usage efficiently is true; LRU requires hardware support or additional data structures to track usage efficiently.
LRU can be implemented with O(1) time complexity per page reference using a stack is false; a stack alone cannot provide O(1) updates on every reference.
LRU always performs better than FIFO regardless of workload is false; LRU can perform worse than FIFO in some workloads (e.g., scan patterns).
LRU does not require any extra space beyond the page frames is false; LRU requires extra space for tracking usage metadata.Final Answer:
Option A -> Option AQuick Check:
Efficient LRU needs support beyond just frames.
- Assuming LRU is always better than FIFO
- Believing LRU can be done with no extra space
- Thinking a simple stack suffices for O(1) LRU
Solution
Step 1: Understand single-level index block capacity
A single-level index block can only hold pointers to a fixed number of blocks.Step 2: What if file grows beyond index block capacity?
The single index block cannot hold more pointers, so the file cannot grow further under this scheme.Step 3: Analyze the file cannot grow further; to support larger files, multi-level or combined index schemes must be used
Correct: multi-level or combined index schemes (e.g., multi-level indexing, inode structures) are used to support larger files.Step 4: Analyze the file system automatically converts the file to contiguous allocation to accommodate growth
File systems do not convert allocation methods automatically; contiguous allocation is inflexible for growth.Step 5: Analyze the index block dynamically expands by linking to additional index blocks without performance penalty
Index blocks do not dynamically expand by linking; multi-level indexing is a designed solution.Step 6: Analyze the file system switches to linked allocation for that file to handle the extra blocks
File systems do not switch allocation methods on the fly; allocation method is fixed per file.Final Answer:
Option A -> Option AQuick Check:
Single-level index block limits file size; multi-level indexing needed for large files.
- Believing index blocks can dynamically expand
- Thinking allocation methods switch automatically
- Assuming contiguous allocation can handle dynamic growth easily
