Suppose three people are in a line waiting for a department
Suppose three people are in a line waiting for a department store to open for “the big sale.” When the door opens, all three rush the door, but the door is not big enough for all of them to pass through at once. Describe a solution for addressing this deadlock that will allow all three people to pass through the door. Which of the four necessary deadlock conditions does your solution break?
Solution
The required 4 conditions for a deadlock is that:
1. Mutual Exclusion: As the door is not big enough, it satisfies mutual exclusion, and cannot be breaked for a solution.
2. No pre-emption: As people are going through the door, its unfair to pull the door away from them, or pull the person out of the door. And therefore, it cannot be broken for solution.
3. Hold and Wait: This can be broken, by making a rule such that, no person is allowed to wait at the door, and if he/she want to get in, they have to keep moving.
4. Resource Waiting/Circular Waiting: Its a single resource, and therefore, circular wait will not arise in this case.
The best possible solution is to let everybody go through the door, but no body is allowed to wait at the door, and when one person is at the door, the other person should not intrude, and should wait for the door to become empty.

