Given: A system has R identical resources, P processes competing for them and N is the maximum need of each process. The task is to find the minimum number of Resources required So that deadlock will never occur.
R >= P * (N - 1) + 1
Input : P = 3, N = 4 Output : R >= 10 Input : P = 7, N = 2 Output : R >= 8
Consider, 3 process A, B and C.
Let, Need of each process is 4
Therefore, The maximum resources require will be 3 * 4 = 12 i.e, Give 4 resources to each Process.
And, The minimum resources required will be 3 * (4 – 1) + 1 = 10.
i.e, Give 3 Resources to each of the Process, and we are left out with 1 Resource.
That 1 resource will be given to any of the Process A, B or C.
So that after using that resource by any one of the Process, It left the resources and that resources will be used by any other Process and thus Deadlock will Never Occur.
R >= 10
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Deadlock Prevention and Deadlock Avoidance
- Introduction of Deadlock in Operating System
- Deadlock Detection Algorithm in Operating System
- Recovery from Deadlock in Operating System
- Conditions for Deadlock in Operating System
- Deadlock Ignorance in Operating System
- Free space management in Operating System
- Operating Systems | Deadlock | Question 1
- Operating Systems | Deadlock | Question 2
- Hierarchical Deadlock Detection in Distributed System
- System Protection in Operating System
- User View Vs Hardware View Vs System View of Operating System
- System Programs in Operating System
- File System Implementation in Operating System
- Xv6 Operating System -adding a new system call
- Traps and System Calls in Operating System (OS)
- Deadlock Prevention And Avoidance
- Deadlock Detection And Recovery
- Deadlock detection in Distributed systems
- Deadlock Detection in Distributed Systems
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.