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
- Starvation
- Race condition
- Multithreading
- Deadlock