Concept:
A deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. To prevent deadlock in a system with $n$ processes and a single type of resource $R$, we analyze the "worst-case" resource allocation.
The fundamental condition to ensure a deadlock-free system is:
\[ \text{Total Resources } (R) \geq \sum_{i=1}^{n} (\text{Maximum Demand of } P_i - 1) + 1 \]
This formula ensures that even in the worst-case scenario (where every process is one resource short of its maximum requirement), there is at least one remaining resource to allow one process to finish.
Step 1: Identify system parameters and calculate the maximum "Wait State".
From the question, we have:
• Total number of processes ($n$) = 3
• Maximum requirement of each process ($Max\_D$) = 2
• Total available resource units ($R$) = 4
The "Wait State" or "Danger Zone" occurs when each process holds as many resources as possible without completing. For each process, this is $(Max\_D - 1)$.
\[ \text{Max resources held without any process finishing} = 3 \times (2 - 1) = 3 \times 1 = 3 \text{ units.} \]
Step 2: Analyze the 4th resource unit.
If the system has only 3 units, the processes could each hold 1 unit and wait forever for the 2nd unit (Deadlock).
However, the system provides 4 units.
• When 3 units are distributed (1 to each process), 1 unit remains free in the pool.
• This 4th unit will be allocated to one of the 3 processes.
• That process will then have $1 + 1 = 2$ units, fulfilling its maximum requirement.
• It will execute to completion and release both its units back to the system.
Step 3: Conclusion on system safety.
Because there is always a way for at least one process to finish and release resources for others, a circular wait can never be sustained. Therefore, deadlock is mathematically impossible in this configuration.