607 views
0 0 votes
Suppose we want to synchronize two concurrent process P and Q using binary semaphore S and T.

Process P:                        Process Q:

     while(1){                            while(1){

        W:                               Y:

          print ‘0’;                          print ‘1’;

          print ‘0’;                          print ‘1’;

        X:                               Z:

    }

Synchronization statements can be inserted only at points W,X,Y,Z. Which of the following can lead to an output starting with ‘00110011’ ?

a. W : P(S)  X : V(S)  Y : P(T)  Z: V(T) and initially S = T= 1

b. W : P(S)  X : V(T)  Y : P(T)  Z: V(S) and initially S = 1 and T= 0

c. W : P(S)  X : V(T)  Y : P(T)  Z: V(S) and initially S = T= 1

d. W : P(S)  X : V(S)  Y : P(T)  Z: V(T) and initially S = 1 and T= 0

1 Answer

0 0 votes
To ensure that the given output is printed we need to take values as S=1 and T=0.
To ensure that it prints only (0011)* only, we need to take W: P(S), X:V(T) not X:V(S) as it leads to printing 0000……
Also, Y:P(T) and Z:V(S) such that 00 can be printed only after 11 is printed.
Therefore, answer is option b.
Position:
Show:

Related questions

0 0 votes
2 2 answers
3.0k
3.0k views
roopkathaaa asked Sep 2, 2023
2,994 views
A system has 5 process and 3 resources (A, B, C). The maximum count of resources are (10, 5, 7). Consider the following table of resource allocation. MAX(A B C)Alloc...
0 0 votes
1 1 answer
1.4k
1.4k views
roopkathaaa asked Sep 2, 2023
1,374 views
State true or false.Deadlock detection is possible using the allocation and request matrices alone.A way to recover from deadlock is to take away the resource from one of...
0 0 votes
1 1 answer
563
563 views
roopkathaaa asked Sep 2, 2023
563 views
Which of the following is false about User threads? User threads can switch fast since it does not involve kernel. User threads are lightweight since they do not require ...
1 1 vote
3 3 answers
1.1k
1.1k views