Wwith 4 processes (P1-P4) and two resources R1-R2 (each with 4 instances), deter
ID: 3902564 • Letter: W
Question
Wwith 4 processes (P1-P4) and two resources R1-R2 (each with 4 instances), determine whether or not there is a deadlock.
Process ID
Current allocation
New request
R1
R2
R1
R2
P1
2
1
2
1
P2
0
1
1
0
P3
1
0
0
1
P4
1
1
2
1
Assuming that the processes now have priorities and ordered as follows: P1 < P2 < P3 < P4 where P4 has the highest priority and P1 the least priority. Let us also assume that the “no preemption” condition is now relaxed by allowing preemption of resources by processes of higher priority. For example, P4 may preempt P3, P2, or P1 if it needs a resource which they are holding. If P4 preempts one of these processes, say P1, then P1 release all the resources it is holding. Show one sequence of events in which resources are allocated to the 4 processes and the resulting preemptions, if any, until all new requests are serviced. Current allocations are shown below. Each resource has 4 instances.
Process ID
Current allocation
New request
R1
R2
R1
R2
P1
2
1
2
1
P2
0
1
1
0
P3
1
0
0
1
P4
1
1
2
1
Process ID
Current allocation
New request
R1
R2
R1
R2
P1
2
1
2
1
P2
0
1
1
0
P3
1
0
0
1
P4
1
1
2
1
Explanation / Answer
We have R1 = 4 , R2 = 4
Currently we have one R2 free
We can allocate it to P3
Now we have 1 R1 and 1 R2 free
We can fullfill P2
Now we have 1 R1 2 R2
Now we are stuck , we can not fullfill any other process. So it is a deadlock
If preemption is allowed, then P4 will preempt P1, P3 will preempt P2, then
P2 will run to completion and then P1 will run to completion
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.