SlideShare una empresa de Scribd logo
1 de 16
BANKER’S ALGORITHM
Prepared by,
Prof. Samina Anjum,
Department CSE, ACET..
SYLLABUS:- Operating System
UNIT DETAILS
I
Introduction: Evolution of OS, Types of OS, Basic h/w support
necessary for modern operating systems, services provided by OS,
system programs and system calls, system design and implementation.
II
File systems: File concept, Access methods, Disk space management
and space allocation strategies, directory structures, Recovery, Log-
structured File System, disk arm scheduling strategies.
III
Scheduling: Process concept, process control block, Types of scheduler,
context switch, threads, multithreading model, goals of scheduling and
different scheduling algorithms, examples from WINDOWS 2000 &
LINUX.
SYLLABUS:- Operating System
UNIT DETAILS
IV
Memory management: Contiguous allocation, Relocation, Paging,
Segmentation, Segmentation with paging, demand paging, page faults
and instruction restart , page replacement algorithms , working sets ,
Locality, Thrashing, Garbage Collection .
V
Process cooperation and synchronization: Concurrency conditions,
Critical section problem, software and hardware solution, semaphores,
conditional critical regions and monitors, classical inter process
communication problems.
VI
Deadlocks & Protection: Deadlock definition, Prevention, Avoidance,
Detection and recovery, Goals of Protection, access matrix,
COURSE OUTCOME
CO.6 Define deadlock and implement methods for its
avoidance, detection and identify goals of protection.
Banker’s Algorithm
• Banker’s Algorithm is used to determine whether a process’s
request for allocation of resources be safely granted
immediately.
or
• The grant of request be deferred to a later stage.
• For the banker’s algorithm to operate, each process has to a
priori specify its maximum requirement of resources.
• A process is admitted for execution only if its maximum
requirement of resources is within the system capacity of
resources.
•The Banker’s algorithm is an example of resource allocation
policy that avoids deadlock.
Example:- Consider the following table of a system:
Process Allocated Max Available
R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4
P1 0 0 1 2 0 0 1 2 2 1 0 0
P2 2 0 0 0 2 7 5 0
P3 0 0 3 4 6 6 5 0
P4 2 3 5 4 4 3 5 6
P5 0 3 3 2 0 6 5 2
1. Compute NEED Matrix.
2. Is the system in safe state? Justify.
Solution:- Consider the following table of the system:
Process Allocated Max Available
R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4
P1 0 0 1 2 0 0 1 2 2 1 0 0
P2 2 0 0 0 2 7 5 0
P3 0 0 3 4 6 6 5 0
P4 2 3 5 4 4 3 5 6
P5 0 3 3 2 0 6 5 2
1. Compute NEED Matrix = ?
Need [i] = Max[i] - Allocated[i],
Therefore,
Need Matrix
NEED
MATRIX
R1 R2 R3 R4
P1 0 0 0 0
P2 0 7 5 0
P3 6 6 2 2
P4 2 0 0 0
P5 0 3 2 0
2. Is the system is Safe State?
By applying the Banker’s Algorithm:
Let Avail = Available; i.e . Avail = {2,1,0,0}
Iteration 1. Check all processes from P1 to P5.
For P1:
if (P1 Need < Avail )TRUE
then calculate
Avail= Avail + Allocated [P1]
= {2,1,0,0} + = {0,0,1,2}
Avail = {2,1,1,2}
2. Is the system is Safe State?
By applying the Banker’s Algorithm:
Iteration 1.
For P2:
if (P2 Need < Avail )FALSE
//then Check for next process.
For P3:
if (P3 Need < Avail ) FALSE
//then Check for next process.
2. Is the system is Safe State?
By applying the Banker’s Algorithm:
Iteration 1.
For P4:
if (P4 Need < Avail )TRUE
then calculate
Avail= Avail + Allocated [P4]
= {2,1,1,2} + = {2,3,5,4}
Avail = {4,4,6,6}
2. Is the system is Safe State?
By applying the Banker’s Algorithm:
Iteration 1.
For P5:
if (P5 Need < Avail )TRUE
then calculate
Avail= Avail + Allocated [P5]
= {4,4,6,6} + = {0,3,3,2}
Avail = {4,7,9,8}
2. Is the system is Safe State?
By applying the Banker’s Algorithm:
Iteration 2. Check only process P2 to P3.
For P2:
if (P2 Need < Avail )TRUE
then calculate
Avail= Avail + Allocated [P2]
= {4,7,9,8} + = {2,0,0,0}
Avail = {6,7,9,8}
2. Is the system is Safe State?
By applying the Banker’s Algorithm:
Iteration 2. Check only process P2 to P3.
For P3:
if (P3 Need < Avail )TRUE
then calculate
Avail= Avail + Allocated [P3]
= {6,7,9,8} + = {0,0,3,4}
Avail = {6,7,12,12} =System Capacity
Since, all the processes got TRUE marked, no further iterations
are required.
Therefore, Safe Sequence = P1, P4, P5, P2 , P3
Therefore, the System is in the Safe State.
THANKYOU!

Más contenido relacionado

Similar a bankers-algorithm2.pptx

CHAPTER READING TASK OPERATING SYSTEM
CHAPTER READING TASK OPERATING SYSTEMCHAPTER READING TASK OPERATING SYSTEM
CHAPTER READING TASK OPERATING SYSTEM
Nur Atiqah Mohd Rosli
 
Phase II Executive Summary 12.14.14
Phase II Executive Summary 12.14.14Phase II Executive Summary 12.14.14
Phase II Executive Summary 12.14.14
haney888
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
tech2click
 
17 2 expert systems
17 2 expert systems17 2 expert systems
17 2 expert systems
Tianlu Wang
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OS
C.U
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013
Valeriy Kravchuk
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
C.U
 
Lecture 5- Process Synchronization (1).pptx
Lecture 5- Process Synchronization (1).pptxLecture 5- Process Synchronization (1).pptx
Lecture 5- Process Synchronization (1).pptx
Amanuelmergia
 

Similar a bankers-algorithm2.pptx (20)

BITS 1213 - OPERATING SYSTEM (PROCESS,THREAD,SYMMETRIC MULTIPROCESSOR,MICROKE...
BITS 1213 - OPERATING SYSTEM (PROCESS,THREAD,SYMMETRIC MULTIPROCESSOR,MICROKE...BITS 1213 - OPERATING SYSTEM (PROCESS,THREAD,SYMMETRIC MULTIPROCESSOR,MICROKE...
BITS 1213 - OPERATING SYSTEM (PROCESS,THREAD,SYMMETRIC MULTIPROCESSOR,MICROKE...
 
Os task
Os taskOs task
Os task
 
CHAPTER READING TASK OPERATING SYSTEM
CHAPTER READING TASK OPERATING SYSTEMCHAPTER READING TASK OPERATING SYSTEM
CHAPTER READING TASK OPERATING SYSTEM
 
Distributed Operating System_2
Distributed Operating System_2Distributed Operating System_2
Distributed Operating System_2
 
An Autonomous Self-Assessment Application to Track the Efficiency of a System...
An Autonomous Self-Assessment Application to Track the Efficiency of a System...An Autonomous Self-Assessment Application to Track the Efficiency of a System...
An Autonomous Self-Assessment Application to Track the Efficiency of a System...
 
G017113537
G017113537G017113537
G017113537
 
The implementation of Banker's algorithm, data structure and its parser
The implementation of Banker's algorithm, data structure and its parserThe implementation of Banker's algorithm, data structure and its parser
The implementation of Banker's algorithm, data structure and its parser
 
Phase II Executive Summary 12.14.14
Phase II Executive Summary 12.14.14Phase II Executive Summary 12.14.14
Phase II Executive Summary 12.14.14
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
17 2 expert systems
17 2 expert systems17 2 expert systems
17 2 expert systems
 
Critical section operating system
Critical section  operating systemCritical section  operating system
Critical section operating system
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OS
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Macy's: Changing Engines in Mid-Flight
Macy's: Changing Engines in Mid-FlightMacy's: Changing Engines in Mid-Flight
Macy's: Changing Engines in Mid-Flight
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
Introduction to SLURM
Introduction to SLURMIntroduction to SLURM
Introduction to SLURM
 
Report On HMS
Report On HMSReport On HMS
Report On HMS
 
Run time storage
Run time storageRun time storage
Run time storage
 
Lecture 5- Process Synchronization (1).pptx
Lecture 5- Process Synchronization (1).pptxLecture 5- Process Synchronization (1).pptx
Lecture 5- Process Synchronization (1).pptx
 

Más de jamilmalik19 (11)

Evolution of Database Technology.pptx
Evolution of Database Technology.pptxEvolution of Database Technology.pptx
Evolution of Database Technology.pptx
 
Deadlocks.ppt
Deadlocks.pptDeadlocks.ppt
Deadlocks.ppt
 
Evolution of Database Technology.pptx
Evolution of Database Technology.pptxEvolution of Database Technology.pptx
Evolution of Database Technology.pptx
 
CD Store Management.pptx
CD Store Management.pptxCD Store Management.pptx
CD Store Management.pptx
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++
 
Introduction to DSA
Introduction to DSAIntroduction to DSA
Introduction to DSA
 
Wildcard In database
Wildcard In databaseWildcard In database
Wildcard In database
 
Angular momentum
Angular momentumAngular momentum
Angular momentum
 
What is IDE in C++?
What is IDE in C++?What is IDE in C++?
What is IDE in C++?
 
introduction to C++.pptx
introduction to C++.pptxintroduction to C++.pptx
introduction to C++.pptx
 
Data Types and variables in C++.pptx
Data Types and variables in C++.pptxData Types and variables in C++.pptx
Data Types and variables in C++.pptx
 

Último

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

bankers-algorithm2.pptx

  • 1. BANKER’S ALGORITHM Prepared by, Prof. Samina Anjum, Department CSE, ACET..
  • 2. SYLLABUS:- Operating System UNIT DETAILS I Introduction: Evolution of OS, Types of OS, Basic h/w support necessary for modern operating systems, services provided by OS, system programs and system calls, system design and implementation. II File systems: File concept, Access methods, Disk space management and space allocation strategies, directory structures, Recovery, Log- structured File System, disk arm scheduling strategies. III Scheduling: Process concept, process control block, Types of scheduler, context switch, threads, multithreading model, goals of scheduling and different scheduling algorithms, examples from WINDOWS 2000 & LINUX.
  • 3. SYLLABUS:- Operating System UNIT DETAILS IV Memory management: Contiguous allocation, Relocation, Paging, Segmentation, Segmentation with paging, demand paging, page faults and instruction restart , page replacement algorithms , working sets , Locality, Thrashing, Garbage Collection . V Process cooperation and synchronization: Concurrency conditions, Critical section problem, software and hardware solution, semaphores, conditional critical regions and monitors, classical inter process communication problems. VI Deadlocks & Protection: Deadlock definition, Prevention, Avoidance, Detection and recovery, Goals of Protection, access matrix,
  • 4. COURSE OUTCOME CO.6 Define deadlock and implement methods for its avoidance, detection and identify goals of protection.
  • 5. Banker’s Algorithm • Banker’s Algorithm is used to determine whether a process’s request for allocation of resources be safely granted immediately. or • The grant of request be deferred to a later stage. • For the banker’s algorithm to operate, each process has to a priori specify its maximum requirement of resources. • A process is admitted for execution only if its maximum requirement of resources is within the system capacity of resources. •The Banker’s algorithm is an example of resource allocation policy that avoids deadlock.
  • 6. Example:- Consider the following table of a system: Process Allocated Max Available R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P1 0 0 1 2 0 0 1 2 2 1 0 0 P2 2 0 0 0 2 7 5 0 P3 0 0 3 4 6 6 5 0 P4 2 3 5 4 4 3 5 6 P5 0 3 3 2 0 6 5 2 1. Compute NEED Matrix. 2. Is the system in safe state? Justify.
  • 7. Solution:- Consider the following table of the system: Process Allocated Max Available R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P1 0 0 1 2 0 0 1 2 2 1 0 0 P2 2 0 0 0 2 7 5 0 P3 0 0 3 4 6 6 5 0 P4 2 3 5 4 4 3 5 6 P5 0 3 3 2 0 6 5 2 1. Compute NEED Matrix = ? Need [i] = Max[i] - Allocated[i], Therefore,
  • 8. Need Matrix NEED MATRIX R1 R2 R3 R4 P1 0 0 0 0 P2 0 7 5 0 P3 6 6 2 2 P4 2 0 0 0 P5 0 3 2 0
  • 9. 2. Is the system is Safe State? By applying the Banker’s Algorithm: Let Avail = Available; i.e . Avail = {2,1,0,0} Iteration 1. Check all processes from P1 to P5. For P1: if (P1 Need < Avail )TRUE then calculate Avail= Avail + Allocated [P1] = {2,1,0,0} + = {0,0,1,2} Avail = {2,1,1,2}
  • 10. 2. Is the system is Safe State? By applying the Banker’s Algorithm: Iteration 1. For P2: if (P2 Need < Avail )FALSE //then Check for next process. For P3: if (P3 Need < Avail ) FALSE //then Check for next process.
  • 11. 2. Is the system is Safe State? By applying the Banker’s Algorithm: Iteration 1. For P4: if (P4 Need < Avail )TRUE then calculate Avail= Avail + Allocated [P4] = {2,1,1,2} + = {2,3,5,4} Avail = {4,4,6,6}
  • 12. 2. Is the system is Safe State? By applying the Banker’s Algorithm: Iteration 1. For P5: if (P5 Need < Avail )TRUE then calculate Avail= Avail + Allocated [P5] = {4,4,6,6} + = {0,3,3,2} Avail = {4,7,9,8}
  • 13. 2. Is the system is Safe State? By applying the Banker’s Algorithm: Iteration 2. Check only process P2 to P3. For P2: if (P2 Need < Avail )TRUE then calculate Avail= Avail + Allocated [P2] = {4,7,9,8} + = {2,0,0,0} Avail = {6,7,9,8}
  • 14. 2. Is the system is Safe State? By applying the Banker’s Algorithm: Iteration 2. Check only process P2 to P3. For P3: if (P3 Need < Avail )TRUE then calculate Avail= Avail + Allocated [P3] = {6,7,9,8} + = {0,0,3,4} Avail = {6,7,12,12} =System Capacity
  • 15. Since, all the processes got TRUE marked, no further iterations are required. Therefore, Safe Sequence = P1, P4, P5, P2 , P3 Therefore, the System is in the Safe State.