342 views
0 votes
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 votes
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.

Related questions

1.8k
views
2 answers
0 votes
roopkathaaa asked Sep 2, 2023
1,778 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 ... P0, P2 only P2, P4, P3, P1, P0 only Both a and b None are safe sequences
894
views
1 answers
0 votes
roopkathaaa asked Sep 2, 2023
894 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 ... True, False False, True, True True, False, True False, True, False
301
views
1 answers
0 votes
roopkathaaa asked Sep 2, 2023
301 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 ... every user threads i.e. if it is blocking or runnable. None of these