-
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-sex (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 :
1. The above solution to CS problem is deadlock-free.
2. The solution is starvation-free.
3. The processes enter CS in FIFO order.
4. More than one processes can enter CS at the same time.
Which of the above statements is true?
-
- 1 only
- 1 and 2
- 2 and 3
- 4 only
- 1 only
Correct Option: A
The given program initializes the memory location X to 0 in the test and set instruction and in the function leave_CS().
∴ Above solution is deadlock free.