447 views
0 votes
0 votes

The E_CS() and L_CS() functions to implement critical section of a process are realized using Test-and-Set instruction as stated below:

void E_CS(X) 
{
    while(Test-and-Set(X); 
} 
void L_CS(X) 
{ 
    X=0;
}

In above code snippet, X is a memory location associated with CS and is initialized to 0. Which among these statements are True regarding the given solution?

  1. it is deadlock free solution
  2. it is starvation free solution
  3. the process enter into CS in FIFO order
  4. more than 1 process can enter into CS at same time 
    1. i only
    2. i and ii
    3. ii and iii
    4. iv only

2 Answers

0 votes
0 votes

Given in the question, process are realized using Test-and-Set instruction

Test-and-Set instruction → an instruction used to write 1 (set) to a memory location and return its old value as a single atomic (i.e., non-interruptible) operation.

So , given module E_CS(X) will work as as wait function (P) AND L_CS(X) as signal/wakeup function (V).

Here 1 value of X means wait state And 0 means free (complement of what we normally use for semaphores)

So the given implementation is deadlock free (due to atomicity of Test-and-Set instruction) .

Here since there’s no bounded waiting (any process can be given CS no scheduling/queue), Hence starvation is possible.

 

So answer should be option (A)

 

Answer:

Related questions

1 votes
1 votes
2 answers
1