CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ

Two processes use `while (lock) ; lock = 1; /* CS */ lock = 0;` with a plain shared variable (no atomic instruction). Which requirement of the critical-section problem fails?

  1. A. Progress, because a process outside the CS can block others
  2. B. Bounded waiting only, while mutual exclusion still holds
  3. C. None of them; it is correct whenever only one CPU is present
  4. D. Mutual exclusion, since both can read lock == 0 before either sets it

Correct answer: D. Mutual exclusion, since both can read lock == 0 before either sets it

The test and the set are separate steps, so both processes can read 0, both set it to 1 and both enter. A test-and-set or compare-and-swap makes the check and update atomic; even on one CPU a preemption between them breaks it.

More Operating Systems questions

Exams that ask this topic