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?
- A. Progress, because a process outside the CS can block others
- B. Bounded waiting only, while mutual exclusion still holds
- C. None of them; it is correct whenever only one CPU is present
- 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
- In Peterson's algorithm for P0 and P1, the entry code for Pi is flag[i] = true; turn = j; while (flag[j] && turn == j);. What goes wrong…
- A counting semaphore is implemented WITHOUT busy waiting, and its value is −3 at some moment. What does this tell you?
- Which statement about user-level threads in a many-to-one model is correct?
- A system has 4 instances of R1 and 2 of R2. Allocated: P1 holds 1 R1; P2 holds 2 R1 and 1 R2; P3 holds 1 R1 and 1 R2. Requests: P1 wants 1…
- Which statement about a process that calls exec() successfully is correct?
- A logical address space has 8 pages of 2 KB each, and physical memory has 32 frames. How many bits are in a logical address and in a…