0% found this document useful (0 votes)
96 views17 pages

Deadlock Avoidance Banker

Uploaded by

syed.12682
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views17 pages

Deadlock Avoidance Banker

Uploaded by

syed.12682
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Deadlock Avoidance Banker's Algorithm

It is also utilized as Deadloack Detection


Deadlock Avoidance Banker's Algorithm
Process Allocation Max Need Available Remaining Need
A B C A B C A B C A B C
1 0 1 0 7 5 3
2 2 0 0 3 2 2
3 3 0 2 9 0 2
4 2 1 1 4 2 2
5 0 0 2 5 3 3
Deadlock Avoidance Banker's Algorithm
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3
2 2 0 0 3 2 2
3 3 0 2 9 0 2
4 2 1 1 4 2 2
5 0 0 2 5 3 3
Total 7 2 5

Safe sequence
Total A=10, B=5, C=7
Unsafe
CPU Printer

Memory
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2
2 2 0 0 3 2 2
3 3 0 2 9 0 2
4 2 1 1 4 2 2
5 0 0 2 5 3 3
Total 7 2 5

Safe sequence
Total A=10, B=5, C=7
Unsafe
CPU Printer

Memory
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 7 4 3
2 2 0 0 3 2 2 1 2 2
3 3 0 2 9 0 2 6 0 0
4 2 1 1 4 2 2 2 1 1
5 0 0 2 5 3 3 5 3 1
Total 7 2 5

Remaining Need=Max need- Allocation


Total A=10, B=5, C=7

CPU Printer
Safe sequence
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Here, Compare remaining
Resouces A B C A B C A B C A B C Need withcurrent availability ,
1 0 1 0 7 5 3 3 3 2 7 4 3 of P1. P1 cannot execute
because it not fullfill all
2 2 0 0 3 2 2 1 2 2
instance of current availability
3 3 0 2 9 0 2 6 0 0
4 2 1 1 4 2 2 2 1 1 Check P2 it can execute
5 0 0 2 5 3 3 5 3 1 because it fullfill all instance of
current availability , it will
Total 7 2 5 come in safe sequence
list.After it execution it release
Total A=10, B=5, C=7 already allocated resources
too.
CPU Printer
Safe sequence P2,
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C Here, P1 cannot execute
1 0 1 0 7 5 3 3 3 2 7 4 3 because it not fullfill all
instance of current availability
2 2 0 0 3 2 2 5 3 2 1 2 2
3 3 0 2 9 0 2 6 0 0 Check P2 it can execute
because it fullfill all instance of
4 2 1 1 4 2 2 2 1 1
current availability , it will
5 0 0 2 5 3 3 5 3 1 come in safe sequence
Total 7 2 5 list.After it execution it release
already allocated resources
too.
Total A=10, B=5, C=7
Now add P2 allocated in current availability and update it
CPU Printer
Safe sequence P2,
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C Check P3 it cannot execute
because it inot fullfill all
1 0 1 0 7 5 3 3 3 2 7 4 3
instance of current availability
2 2 0 0 3 2 2 5 3 2
3 3 0 2 9 0 2 6 0 0
4 2 1 1 4 2 2 2 1 1
5 0 0 2 5 3 3 5 3 1
Total 7 2 5

Total A=10, B=5, C=7

CPU Printer
Safe sequence P2,
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 7 4 3 Check P4 it can execute
because it fullfill all instance of
2 2 0 0 3 2 2 5 3 2
current availability , it will
3 3 0 2 9 0 2 7 4 3 6 0 0 come in safe sequence
4 2 1 1 4 2 2 2 1 1 list.After it execution it release
already allocated resources
5 0 0 2 5 3 3 5 3 1 too.
Total 7 2 5

Total A=10, B=5, C=7


Now add P4 allocated in current availability and update it
CPU Printer
Safe sequence P2,P4
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 7 4 3 Check P4 it can execute
because it fullfill all instance of
2 2 0 0 3 2 2 5 3 2
current availability , it will
3 3 0 2 9 0 2 7 4 3 6 0 0 come in safe sequence
4 2 1 1 4 2 2 list.After it execution it release
already allocated resources
5 0 0 2 5 3 3 5 3 1 too.
Total 7 2 5

Total A=10, B=5, C=7

CPU Printer
Safe sequence P2,P4
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 7 4 3 Check P5 it can execute
because it fullfill all instance of
2 2 0 0 3 2 2 5 3 2
current availability , it will
3 3 0 2 9 0 2 7 4 3 6 0 0 come in safe sequence
4 2 1 1 4 2 2 7 4 5 list.After it execution it release
already allocated resources
5 0 0 2 5 3 3 5 3 1 too.
Total 7 2 5

Total A=10, B=5, C=7


Now add P5 allocated in current availability and update it
CPU Printer
Safe sequence P2,P4, P5
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 7 4 3 Check P5 it can execute
because it fullfill all instance of
2 2 0 0 3 2 2 5 3 2
current availability , it will
3 3 0 2 9 0 2 7 4 3 6 0 0 come in safe sequence
4 2 1 1 4 2 2 7 4 5 list.After it execution it release
already allocated resources
5 0 0 2 5 3 3 too.
Total 7 2 5

Total A=10, B=5, C=7

CPU Printer
Safe sequence P2,P4, P5
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 7 4 3 NowCheck P1 it can execute
now because it fullfill all
2 2 0 0 3 2 2 5 3 2
instance of current
3 3 0 2 9 0 2 7 4 3 6 0 0 availability , it will come in
4 2 1 1 4 2 2 7 4 5 safe sequence list.After it
execution it release already
5 0 0 2 5 3 3 allocated resources too.
Total 7 2 5

Total A=10, B=5, C=7


Now add P1 allocated in current availability and update it
CPU Printer
Safe sequence P2,P4, P5, P1
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 NowCheck P1 it can execute
now because it fullfill all
2 2 0 0 3 2 2 5 3 2
instance of current
3 3 0 2 9 0 2 7 4 3 6 0 0 availability , it will come in
4 2 1 1 4 2 2 7 4 5 safe sequence list.After it
execution it release already
5 0 0 2 5 3 3 7 5 5 allocated resources too.
Total 7 2 5

Total A=10, B=5, C=7


Now add P1 allocated in current availability and update it
CPU Printer
Safe sequence P2,P4, P5,P1
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 NowCheck P3 it can execute
now because it fullfill all
2 2 0 0 3 2 2 5 3 2
instance of current
3 3 0 2 9 0 2 7 4 3 6 0 0 availability , it will come in
4 2 1 1 4 2 2 7 4 5 safe sequence list.After it
execution it release already
5 0 0 2 5 3 3 7 5 5 allocated resources too.
Total 7 2 5

Total A=10, B=5, C=7


Now add P3 allocated in current availability and update it
CPU Printer
Safe sequence P2,P4, P5,P1, P3
Memory
Unsafe
Deadlock Avoidance Banker's Algorithm
Current availability
Process Allocation Max Need Available Remaining Need
Resouces A B C A B C A B C A B C
1 0 1 0 7 5 3 3 3 2 NowCheck P3 it can execute
now because it fullfill all
2 2 0 0 3 2 2 5 3 2
instance of current
3 3 0 2 9 0 2 7 4 3 availability , it will come in
4 2 1 1 4 2 2 7 4 5 safe sequence list.After it
execution it release already
5 0 0 2 5 3 3 7 5 5 allocated resources too.
Total 7 2 5 10 5 7

Total A=10, B=5, C=7


Now add P3 allocated in current availability and update it
CPU Printer
Safe sequence P2, P4, P5, P1, P3
Memory
This safe sequence shows there
Unsafe is no deadlock occur
Deadloack occurs whenever it not fullfill any instance of current availability that called unsafe condition.
Deadlock Avoidance Banker's Algorithm
Practice
Process Allocation Max Need Available Remaining Need
A B C A B C A B C A B C
1 1 0 1 4 3 1 3 3 0
2 1 1 2 2 1 4
3 1 0 3 1 3 3
4 2 0 0 5 4 1
Total 5 1 6

You might also like