1,237 views
0 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 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:
Position:
Show:

Related questions

1 1 vote
2 answers 2 answers
732
732 views
Bikram asked Sep 3, 2016
732 views
At a particular time of computation, the value of a counting semaphore is $7$ , then $20$ $P$ operations and 'x' $V$ operations were completed on this semaphore. If the f...
6 6 votes
5 answers 5 answers
2.3k
2.3k views
Bikram asked Sep 3, 2016
2,335 views
Each process $P_i$, where $i= 1$ to $9$ is coded as follows repeat P (mutex) {critical section } V (mutex) foreverThe code for $P_{10}$ is identical except that it uses ...
1 1 vote
2 2 answers
1.6k
1.6k views
Bikram asked Sep 3, 2016
1,564 views
Two concurrent processes P1 and P2 want to use 2 resources J1 and J2 in a Mutually Exclusive way. Assume that initially J1 and J2 are both free. The programs executed by ...
6 6 votes
1 1 answer
1.8k
1.8k views
Bikram asked Sep 3, 2016
1,845 views
Consider Peterson's algorithm for Mutual Exclusion between two concurrent processes $w$ and $f$. The program executed by the processeses are shown below:Process wProcess ...