532 views
2 votes
2 votes

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

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
1
Mrityudoot asked Jan 27
229 views
Can a counting semaphore acquire a negative value?S = 2;15 P operations done, should the semaphore be 0 or -13
1 votes
1 votes
1 answer
2
0 votes
0 votes
1 answer
3
Na462 asked Jul 19, 2018
568 views
0 votes
0 votes
1 answer
4
Na462 asked Jul 14, 2018
709 views