-
Consider the following policies for preventing deadlock in a system with mutually exclusive resources.
i. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released.
ii. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers
iii. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers
iv. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources
Which of the above policies can be used for preventing deadlock?
-
- Any one of i and iii but not ii or iv
- Any one of i, iii, and iv but not ii
- Any one of ii, and iii but not i or iv
- Any one of i, ii, iii, and iv
- Any one of i and iii but not ii or iv
Correct Option: D
For deadlock prevention we need to dissatisfy any of the necessary condition for deadlock
1. For hold and wait if we dissatisfy it can be hold or wait for hold …before process start os assign all resources. While executing if process making new resource request it has to release all its assign resources that is waiting for release resources.
2. If we dissatisfy circular wait condition suppose there r five resources uniquely numbered r1 to r5 and there five processes p1 to p5 suppose p2 hold r1, and requesting for r2, and r2 hold by p3 and wait for r3, r3 hold by p4 wait for r4 which is hold by p5 and wait for r5 which is held by p1 (this is happening in circular manner)(condition to come out from circular wait is a process can hold the resource and request for new resource only when holding resource id is lesser then requesting resource id) in above p1 is violating condition.
3. If we dissatisfy preemption if a process hold some resources requesting for new resources and that requesting resources are busy with some other process requesting process voluntarily release its held resources.
According to 1 and 3 above statements, first statement (i) is correct.
According to above second statement, second statement (ii) is correct.
According to above second statement if we implement the logic in reverse order then the third statement (iii) is also correct.
According to second statement condition statement (iv) is also correct.