CS FundamentalsHardGATE CS

Binary semaphore mutex = 1 protects a counter. A programmer mistakenly writes `signal(mutex); /* critical section */ wait(mutex);` in every process. What happens?

  1. A. Several processes can be in the critical section at once
  2. B. The first process to run deadlocks
  3. C. Only one process ever enters, then all others starve
  4. D. It still works correctly, only slower

Correct answer: A. Several processes can be in the critical section at once

signal first raises mutex to 2 (a counting implementation) or leaves it 1, so each process walks straight in; mutual exclusion is lost. Swapping two waits instead (wait; wait) would cause deadlock.

More Operating Systems questions

Exams that ask this topic