GATE - 2009 | OS | The enter_CS() and leave_CS() functions to implement critical section of

GATE - 2009 | OS | The enter_CS() and leave_CS() functions to implement critical section of
Posted on 14-02-2022

GATE - 2009 [Operating System]

Question:

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?

A

I only

B

I and II

C

II and III

D

IV only

     

Solution:

Option (A) is Correct.

The given solution is the basic test-and-set solution. So there is no possibility of getting deadlock.


It is not using any queue to avoid starvation and there is no use of FIFO.


In CS, only one process can enter.


So, the Answer is option A.

Thank You

Download App for Free PDF Download

GovtVacancy.Net Android App: Download

government vacancy govt job sarkari naukri android application google play store https://play.google.com/store/apps/details?id=xyz.appmaker.juptmh