Question

I have final test in OS Course, in the morning tomorrow, and I got stuck with an problem.

Say we have 4 processes in our system: P1, P2, P3, P4, and 4 different resources: R1, R2, R3, R4. Current state of the system shown in this picture.

enter image description here

The question is - "Is system in deadlock or not?" I solved few similar problems, so, I think, the system IS in deadlock, because there aren't enough available resources (for example P4 requests 2 instances of R3, but in available list exists only 1 resource of R3).

I'm little confused because answer of my practitioner is : system isn't in deadlock, and processes running in this order: P4->P3->P1->P2

Which Solution is Right?

Thanks.

Was it helpful?

Solution

Your instructor is correct. In particular, P4 already has (1 0 1 1), and thus needs only (0 0 1 0), which can be easily met by the available resources. After P4 is served the resources, it completes and releases everything it was using (including its Current Allocation). The OS can then send those resources through to the remaining processes (in the correct sequence), thus no deadlock.

OTHER TIPS

According to the explanation here, P4->P3->P2->P1 wont work, because P2 will make R1 0 , and that can lead to deadlock of P2 goes in loop or is not available for a long time P1 waits for all that time as R1 is zero. ?

As After P3 and P4 are done, Avail Matrix becomes 3334 , which is enough to satisfy needs of P2 as well ?.

safe sequence is p3,p4,p1,p2
p1 false
p2 false
p3 true total 5555 - execute 1st
p4 true total 6566 - execute 2nd
loop cont
p1 true total 7678 - execute 3rd
p2 true total 9788 - execute 4th

safe sequence (p3,p4,p1,p2)

I think the system is in a deadlock because request p4 cannot be satisfied. We don't look at the allocation we look at the request. If it's not satisfied then it's a deadlock. Remember processes are allowed to hold some resources while requesting others

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top