banker's algorithm- deadlock avoidance

28
Deadlock

Upload: chendraayan-jk

Post on 24-Jun-2015

842 views

Category:

Education


1 download

DESCRIPTION

This is an illustration of solving a deadlock avoidance problem using bankers algorithm.. DOWNLOAD and view with animated illustration..

TRANSCRIPT

Page 1: Banker's Algorithm- Deadlock Avoidance

Deadlock

Page 2: Banker's Algorithm- Deadlock Avoidance

DeadlockAvoidance

Page 3: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 3 2

Process Allocation Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 4: Banker's Algorithm- Deadlock Avoidance

Available

A

B

C

Needed A

Needed B

Needed C

P0 P1 P2 P3 P4

Page 5: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 6: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 7: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 8: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 9: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 2 1 0

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 3 2 2 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 10: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 5 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 11: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 5 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 12: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 5 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 13: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 5 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

Page 14: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 5 2 1

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 2 2 2 2 2 2 0 0 0

P4 0 0 2 4 3 3 4 3 1

Page 15: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 4 3

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 2 4 3 3 4 3 1

Page 16: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 4 3

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 2 4 3 3 4 3 1

Page 17: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 1 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 4 3 3 4 3 3 0 0 0

AVAILABLE: 7 4 3

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 2 4 3 3 4 3 1

Page 18: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 4 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

AVAILABLE: 3 1 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 4 3 3 4 3 3 0 0 0

Page 19: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 3 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

AVAILABLE: 7 4 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 20: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 4 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 21: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 4 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 22: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 0 0 2

Process

Allocation

Max Need

A B C A B C A B C

P0 7 5 3 7 5 3 0 0 0

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 23: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 5 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 0 0 7 5 3 0 0 0

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 24: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 5 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 0 0 7 5 3 0 0 0

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 25: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 7 5 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 0 0 7 5 3 0 0 0

P1 0 0 0 3 2 2 0 0 0

P2 3 0 2 9 0 2 6 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 26: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 1 5 5

Process

Allocation

Max Need

A B C A B C A B C

P0 0 0 0 7 5 3 0 0 0

P1 0 0 0 3 2 2 0 0 0

P2 9 0 2 9 0 2 0 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

Page 27: Banker's Algorithm- Deadlock Avoidance

AVAILABLE: 10 5 7

Process

Allocation

Max Need

A B C A B C A B C

P0 0 0 0 7 5 3 0 0 0

P1 0 0 0 3 2 2 0 0 0

P2 0 0 0 9 0 2 0 0 0

P3 0 0 0 2 2 2 0 0 0

P4 0 0 0 4 3 3 0 0 0

AVAILABLE: 3 3 2

Process

Allocation

Max Need

A B C A B C A B C

P0 0 1 0 7 5 3 7 4 3

P1 2 0 0 3 2 2 1 2 2

P2 3 0 2 9 0 2 6 0 0

P3 2 1 1 2 2 2 0 1 1

P4 0 0 2 4 3 3 4 3 1

FinalInitial

7 2 5

?Calculate Total Initial AllocationAdd it to Initial Available

3 3 2_______

_______10 5 7

How to verify?Thats It

Page 28: Banker's Algorithm- Deadlock Avoidance

Thank You