resource allocation graph

12
v v v P1 P2 P3 R1 R2 R3 R4 Initially No resource is allocated to any process Baljit Singh Saini

Upload: baljitsaini28

Post on 24-Jan-2018

171 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

Initially No resource is allocated to any process

Baljit Singh Saini

Page 2: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

P1 requests R2 One instance of R2 is allocated to P1

Baljit Singh Saini

Page 3: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

P2 requests R1 R1 is allocated to P2

Baljit Singh Saini

Page 4: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

P3 requests R3 R3 is allocated to P3

Baljit Singh Saini

Page 5: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

P2 requests R2 One instance of R2 is allocated to P2

Baljit Singh Saini

Page 6: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

P1 requests R1 Request Can not be fulfilled as R1 is being used by P2

Will there be a deadlock?

No. Circular wait is not satisfied

Baljit Singh Saini

Page 7: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

P2 requests R3 Request Can not be fulfilled as R3 is being used by P3

Still no deadlock

Baljit Singh Saini

Circular wait is not satisfied and

also hold and wait

Page 8: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

Still no deadlock

Since P3 after finishing can release R3, which can be then allocated to P2.

Baljit Singh Saini

Page 9: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

Still no deadlock

Since P3 after finishingcan release R3, whichcan be then allocatedto P2.

P2 will have all therequired resources. Itcan finish and thenrelease R1, which canbe allocated to P1

Finally P1 will have all the required resources.

Baljit Singh Saini

Page 10: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

Now suppose P3 requests R2 Request Can not be fulfilled as no instance of R2 is free

Will there be a deadlock situation?

YES

Baljit Singh Saini

Page 11: Resource allocation graph

v

v v

P1 P2 P3

R1

R2

R3

R4

Cycle 1 : P1 -> R1 -> P2 - > R3 -> P3 -> R2 -> P1

Cycle 2 : P2 - > R3 -> P3 -> R2 -> P2

Baljit Singh Saini

Page 12: Resource allocation graph

Is there a deadlock?

P1 P3

P2

P4

R1

R2

No, because P2 and P4 are not satisfying Hold

and Wait.

NO

Baljit Singh Saini