Semaphores are used to solve the problem of I. Race Condition II. Process…
2015
Semaphores are used to solve the problem of
I. Race Condition
II. Process Synchronization
III. Mutual Exclusion
IV. None of the above
- A.
I and II
- B.
II and III
- C.
All of the above
- D.
None of the above
Attempted by 289 students.
Show answer & explanation
Correct answer: C
Concept: A semaphore is a synchronization primitive - an integer counter that processes may act on only through the atomic operations wait() (which blocks the calling process if the counter is not positive, else decrements it) and signal() (which increments the counter and may wake a waiting process). Because every process must pass through this same gate before touching a shared resource, one primitive simultaneously gives three guarantees: it lets only one process (or a fixed number of processes) hold the resource at a time (mutual exclusion), it lets one process make another wait until a condition is met (process synchronization / ordering), and it removes the unsynchronized concurrent read-modify-write that causes a race condition.
Application to this item:
I. Race Condition - When two processes access shared data without coordination, the final result depends on the unpredictable order of their execution. A semaphore forces every process to acquire it via wait() before touching the shared data, so accesses are serialized and the outcome no longer depends on timing.
II. Process Synchronization - wait() and signal() let one process block until another process signals that a precondition is satisfied, so a semaphore can enforce a required execution order between cooperating processes (for example, a consumer waiting for a producer).
III. Mutual Exclusion - A binary semaphore initialised to 1 acts as a lock around a critical section: wait() admits exactly one process, and every other process calling wait() blocks until that process calls signal() on exit, so only one process is ever inside the critical section at a time.
Cross-check: All three guarantees trace back to the single wait()/signal() gate described above, so a semaphore is not limited to any one of them - it is a general-purpose tool for all three. That rules out any option that names only a subset (I & II, or II & III) or denies all three (None of the above); the option that includes all three, All of the above, is the one supported by the definition.
A video solution is available for this question — log in and enroll to watch it.