Practice
Solution
Step 1: Understand Peterson's turn variable role
When both processes set their flags and turn, the turn variable decides who waits.Step 2: Mutual exclusion enforcement
The process whose turn it is not will wait until the other finishes, ensuring only one enters the critical section.Step 3: Deadlock and race condition avoidance
Peterson's algorithm prevents both deadlock and simultaneous entry.Final Answer:
Option C -> Option CQuick Check:
Mutual exclusion is guaranteed by the turn variable and flags.
- Believing both can enter critical section simultaneously
- Thinking the last to set turn always goes first
- Assuming deadlock can occur here
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: Review binary semaphore properties
Binary semaphores do not enforce ownership; any thread can signal.Step 2: Review mutex properties
Mutex enforces ownership; only locking thread can unlock.Step 3: Analyze each statement
A is correct; B is correct; C is incorrect because binary semaphores lack ownership enforcement; D is correct.Final Answer:
Option C -> Option CQuick Check:
Binary semaphore ownership enforcement is the key difference from mutex.
- Assuming binary semaphore enforces ownership like mutex
- Confusing signaling with mutual exclusion
- Believing mutexes are used for signaling
Solution
Step 1: Understand paged segmentation
Address translation involves two steps: segment table lookup to get page table base, then page table lookup to get frame.Step 2: Analyze The need to first translate segment number to a page table, then translate page number to frame number
This correctly describes the two-level translation process.Step 3: Analyze The inability to handle variable-sized segments due to fixed page sizes
Variable-sized segments are handled by paging within segments; this option is incorrect.Step 4: Analyze The elimination of external fragmentation but increased internal fragmentation
Fragmentation trade-offs are more complex; this option oversimplifies and is incorrect.Step 5: Analyze The requirement that all segments must be the same size
Segments can vary in size; this option is false.Final Answer:
Option A -> Option AQuick Check:
Paged segmentation requires hierarchical translation: segment -> page table -> frame.
- Assuming paged segmentation removes variable segment sizes
- Thinking all segments must be uniform size
- Confusing fragmentation effects
Solution
Step 1: Understand current mode
Interrupt handlers run in kernel mode with full privileges.Step 2: System call invoked in kernel mode
Since already in kernel mode, no mode switch is needed; system call executes directly.Step 3: Why other options are incorrect
The CPU switches to user mode before executing the system call to prevent privilege escalation. is incorrect; switching to user mode would reduce privileges improperly. The system call is deferred until the interrupt handler finishes and user mode resumes. is wrong; system calls are not deferred. The system call triggers a nested mode switch to a higher privilege level. is false; kernel mode is the highest privilege level, no nested switch occurs.Final Answer:
Option C -> Option CQuick Check:
System call in kernel mode -> no mode switch -> immediate execution [OK]
- Assuming mode switch always occurs on system call
- Thinking system calls are deferred inside kernel
- Believing nested privilege levels exist beyond kernel mode
