![Page 1: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/1.jpg)
Deadlock Avoidance-Banker’s Algorithm
Darsana Babu K Palanisamy
Assistant Professor Assistant Professor
IT ,CIET IT ,CIET
Coimbatore,TamilNadu Coimbatore,TamilNadu
![Page 2: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/2.jpg)
Bankers algorithms Definition
• The algorithm avoids deadlock by denying or postponing the request if it determines that accepting the request could put the system in an unsafe state (one where deadlock could occur).
• When a new process enters a system, it must declare the maximum number of instances of each resource type that it may ever claim; clearly, that number may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time
![Page 3: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/3.jpg)
Algorithm• Step 1: Work=Available Finish=False• Step 2: Find an i such that
Finish[i]=false and Need i <=work if no such I ,go to step4• Step 3: work=work+allocation i finish[i]= True goto step 2• Step 4: If finish[i]=true for all i then the system is safe
![Page 4: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/4.jpg)
Terms
• Available :The number of instances currently available for resource j
• Maximum:themaximum number of instances of resource j that process i can request at anyone time
• Allocation :process i currently holdsinstances of j• Need:process i may need additional instance of
resource
![Page 5: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/5.jpg)
Problem Statement
• There are Five girls they have three different balls Green,Blue ,Red to play.There are 10 Green Balls,5 Blue balls and 7 Red balls .Each girl wants particular number of balls of each colour to play.Since the number of balls is less than the total number of the balls they needed,Once they acquire the ball they will leave the balls they played so that ball can be used by other girls.
• Question How the balls can be passed such that all girl can play
with their balls
![Page 6: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/6.jpg)
• GREEN BLUE RED
![Page 7: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/7.jpg)
5 Friends
LILLYTINTU MITHU
MEENUGITHU
![Page 8: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/8.jpg)
AllocationGREEN BLUE RED
![Page 9: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/9.jpg)
MAXIMUMGREEN BLUE RED
![Page 10: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/10.jpg)
AVAILABLEGREEN BLUE RED
![Page 11: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/11.jpg)
NEEDGREEN BLUE RED
![Page 12: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/12.jpg)
Lilly doesn’t get because available is less than need
GREEN BLUE REDAVAILABLE
<GREEN BLUE RED
![Page 13: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/13.jpg)
Tintu play because Ball available is greater than need
GREEN BLUE REDAVAILABLE
>GREEN BLUE RED
![Page 14: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/14.jpg)
AllocationGREEN BLUE RED
![Page 15: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/15.jpg)
Meenu doesn’t get because available is less than need
GREEN BLUE REDAVAILABLE
<GREEN BLUE RED
![Page 16: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/16.jpg)
Mithu play because Ball available is greater than need
GREEN BLUE REDAVAILABLE
>GREEN BLUE RED
![Page 17: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/17.jpg)
AllocationGREEN BLUE RED
![Page 18: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/18.jpg)
Githu play because Ball available is greater than need
GREEN BLUE REDAVAILABLE
>GREEN BLUE RED
![Page 19: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/19.jpg)
AllocationGREEN BLUE RED
![Page 20: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/20.jpg)
Lilly play because Ball available is greater than need
GREEN BLUE REDAVAILABLE
< GREEN BLUE RED
![Page 21: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/21.jpg)
AllocationGREEN BLUE RED
![Page 22: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/22.jpg)
Meenu play because Ball available is greater than need
GREEN BLUE REDAVAILABLE
>GREEN BLUE RED
![Page 23: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/23.jpg)
Safe sequence
• They play in the following sequence such that all girls gets the ball to play
TINTU MITHU GITHU LILLYMEENU
![Page 24: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/24.jpg)
Problem
• Five processes p0,p1,p2,p3,p4 3 resource types A with 10 instances B with 5 instances and C with 7 instances
• Allocation MAX Available Need
A B C0 1 02 0 03 0 22 1 10 0 2
A B C7 5 33 2 29 0 22 2 24 3 3
A B C
3 3 2
A B C7 4 31 2 26 0 00 1 14 3 1
![Page 25: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/25.jpg)
Solution
Work= Finish =False• P1 :Finish[1]=T;work=• p3:Finish[3]=T ;work=• p4:Finish[4]=T ;work=• p0:Finish[0]=T ;work=• p2:Finish[2]=T ;work=
3 3 2
5 3 2
7 4 3
7 4 5
7 5 5
10 5 7
![Page 26: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/26.jpg)
• Safe sequence is <p1,p3,p4,p0,p2>
![Page 27: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/27.jpg)
Learning outcome
• Students will be able to understand deadlock avoidance
• Students will be able to explain different algorithm with real time arrangement.
• Students will be able to remember it longer
![Page 28: Deadlock Avoidance-Banker’s Algorithm Darsana Babu K Palanisamy Assistant Professor IT,CIET Coimbatore,TamilNadu](https://reader036.vdocument.in/reader036/viewer/2022062503/5a4d1af87f8b9ab0599824ef/html5/thumbnails/28.jpg)
• Thank You