|Que.||Suppose S and Q are two semaphores initialized to 1. P1 and P2 are two processes which are sharing resources.
P1 has statements P2 has statements
wait(S) ; wait(Q) ;
wait(Q) ; wait(S) ;
critical section1; critical section 2;
signal(S) ; signal(Q) ;
signal(Q) ; signal(S) ;
Their execution may sometimes lead to an undesirable situation called