Difficulty: Easy
Correct Answer: 1
Explanation:
Introduction / Context:
Mutual exclusion ensures that concurrent processes do not simultaneously execute a critical section that accesses shared data. A binary semaphore is commonly used to enforce this policy. The correct initial value allows the first entrant and blocks the rest until release.
Given Data / Assumptions:
Concept / Approach:
A binary semaphore initialized to 1 indicates the resource is free. The first P makes it 0, entering the critical section. Any subsequent P calls block (since value is 0) until the current process performs V, restoring the semaphore to 1 and allowing the next process to proceed.
Step-by-Step Solution:
Verification / Alternative check:
Textbook mutex examples and POSIX semaphores mirror this pattern: initial value 1 for a lock-like behavior. Initial value 0 is used for ordering/barrier patterns, not initial entry.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting to release (signal) causing starvation; mixing multiple locks inconsistently causing deadlock; using a counting semaphore inadvertently when exclusivity is required.
Final Answer:
1
Discussion & Comments