The enter_CS() and leave_CS() functions to implement critical section of a…

GATE · 2009 · CS

The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:

void enter_CS(X)

{

while test-and-set(X) ;

}

void leave_CS(X)

{

X = 0;

}

In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider the following statements:

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 is TRUE?

  1. A.

    I only

  2. B.

    I and II

  3. C.

    II and III

  4. D.

    IV only

Attempted by 222 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…