edited by
6,009 views
4 votes
4 votes

Suppose $\text{S}$ and $\text{Q}$ are two semaphores initialized to $1.\;\text{P1}$ and $\text{P2}$ are two processes which are sharing resources.

$\begin{array}{} \textbf{P1 has statements} & \textbf{P2 has statements} \\ \text{wait(S);} & \text{wait(Q);} \\ \text{wait(Q);} & \text{wait(S);} \\ \text{critical-section 1;}& \text{critical-section 2;} \\ \text{signal(S);} & \text{signal(Q);} \\ \text{Signal(Q);} & \text{signal(S);} \\ \end{array}$

Their execution may sometimes lead to an undesirable situation called

  1. Starvation
  2. Race condition
  3. Multithreading
  4. Deadlock
edited by

2 Answers

Best answer
3 votes
3 votes

Ans- D. Deadlock.

Suppose a condition when P1 executes wait(S) and makes S=0. Now P2 executes wait(Q) and makes Q=0. Now neither P1 can execute wait(Q) nor P2 can execute wait(S), because S and Q both are equal to 0. Now P1 is waiting for P2 to release resource Q and P2 is waiting for P1 to release S. Hence neither of them can enter into critical section and are in deadlock condition.

selected by
0 votes
0 votes

one another approach as we can see it satisfies the mutual exclusion 

and it's one of the necessary condition for deadlock

SO Option D.

Answer:

Related questions

2 votes
2 votes
2 answers
1
go_editor asked Jul 19, 2016
2,021 views
The versions of windows operating system like Windows XP and Window Vista uses following file system:FAT-16FAT-32NTFS (NT File System)All of the above
3 votes
3 votes
2 answers
2
go_editor asked Jul 19, 2016
2,871 views
Working set model is used in memory management to implement the concept ofSwappingPrincipal of LocalitySegmentationThrashing