Difficulty: Easy
Correct Answer: 1
Explanation:
Introduction / Context:
Semaphores are fundamental synchronization primitives. For mutual exclusion (mutex), a binary semaphore controls access to a critical section so that only one process can execute inside at once. The initial value determines whether the first process can enter immediately.
Given Data / Assumptions:
Concept / Approach:
A binary semaphore initialized to 1 indicates the resource (critical section) is free. The first P operation decrements it to 0 and grants entry. Additional P attempts block until the semaphore is signaled (V) by the process on exit, restoring it to 1. Initializing to 0 would block everyone at start, requiring an extra signal to begin.
Step-by-Step Solution:
Verification / Alternative check:
Standard textbooks define mutex semaphores with initial value 1. Code examples show semaphore value toggling between 0 and 1 during use.
Why Other Options Are Wrong:
Common Pitfalls:
Using counting semaphores unintentionally; forgetting to signal on exit leading to deadlock; initializing to 0 and wondering why no process proceeds.
Final Answer:
1
Discussion & Comments