Project ForgeSign up free
Operating Systems
Process Synchronization
GATE 2009
Medium

The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction: `void enter_CS(X){ while(test-and-set(X)); } void leave_CS(X){ X=0; }`. X is initialized to 0. Consider: I. The above solution to CS problem is deadlock-free. II. The solution is starvation free. III. The processes enter CS in FIFO order. IV. More than one process can enter CS at the same time. Which of the above statements are TRUE?

  • I only
  • BI and II
  • CII and III
  • DIV only

Explanation

Test-and-set is deadlock-free (some process's atomic test-and-set will always eventually succeed once X becomes 0 — I is true), but provides NO fairness guarantee: a process could be repeatedly overtaken by others (not starvation-free, II false), there's no FIFO ordering (III false), and the atomic test-and-set correctly prevents more than one process entering simultaneously (IV false).

Source: GATE CS 2009 (2009)

This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.

Start revising free