banker's algorithm- deadlock avoidance

Post on 24-Jun-2015

842 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

Deadlock

DeadlockAvoidance

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

A

B

C

Needed A

Needed B

Needed C

P0 P1 P2 P3 P4

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: 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: 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: 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: 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

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

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

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

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

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

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

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

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

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

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

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: 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: 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

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

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

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

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

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

Thank You

top related