search
Log In
2 votes
192 views

If two processes R1 and R2 accessing the shared variables A and B protected by two binary semaphores SA and SB respectively, both initialized to 1.
R and Q denote the usual semaphore operators, where R decrements the semaphore value, and Q increments the semaphore value. The pseudo code of R1 and R2 is as follows:

R1:

while(True){
    do{
        k1:____;
        k2:____;
        a = a+1;
        b = b-1;
        R(SA);
        R(SB);
    }
}

R2:

while(True){ 
    do{
        k3:____;
        k4:____;
        a = a+1;
        b = b-1; 
        R(SB);
        R(SA);
    }
}

The options are :

  • R(SB ),R(SA ),R(SA ),R(SB )
  • R(SB ),R(SA ),R(SB ),R(SA )
  • R(SA ),R(SB ),R(SA ),R(SB )
  • R(SA ),R(SB ),R(SB ),R(SA )
  • None of the above
in Operating System 192 views
0
1st and 3rd option results in deadlock

2nd and 4th can lead to Starvation
0
There is no signal operation in the above transaction .. How semaphore value turn=1 to execute another process.. ?
0

 R decrements the semaphore value, and Q increments the semaphore value

0
there is no Q operation in the given transactions ?

Correct  me if i am wrong
0
oh yeah how did i missed that :o

there is something wrong with the question or answer is none of the above

Please log in or register to answer this question.

Related questions

1 vote
1 answer
1
0 votes
1 answer
2
0 votes
1 answer
3
2 votes
2 answers
4
354 views
Pseudocode: Int x = 0 , y =20; Semaphores SX=1 , SY= 1; Parbegin Begin P(SX) , P(SY) ; X=X+1; V(SY), V(SX); End Begin P(SY) , P(SX) ; X=Y+2; V(SX), V(SY); End Parend Question: Final Values of X? I am getting 1, 22 and deadlock. How come answer is 22, 23 and deadlock possible??
asked Nov 8, 2017 in Operating System vishwa ratna 354 views
...