SlideShare a Scribd company logo
7
Most read
8
Most read
16
Most read
Banker Algorithm in operating system.pptx
 Simplest and most useful model requires that each
process declare the maximum number of resources of
each type that it may need.
 Resource-allocation state is defined by the number of
available and allocated resources, and the maximum
demands of the processes.
 The deadlock-avoidance algorithm dynamically
examines the resource-allocation state to ensure that
there can never be a circular-wait condition.
Requires that the system has some additional a priori information
available.
 When a process requests an available resource, system must decide if
immediate allocation leaves the system in a safe state.
 System is in safe state if there exists a safe sequence of all
processes.
 Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources that Pi
can still request can be satisfied by currently available resources +
resources held by all the Pj, with j<I.
 If Pi resource needs are not immediately available, then Pi can wait until all
Pj have finished.
 When Pj is finished, Pi can obtain needed resources, execute, return
allocated resources, and terminate.
 When Pi terminates, Pi+1 can obtain its needed resources, and so on.
 If a system is in safe state  no deadlocks.
 If a system is in unsafe state  possibility of deadlock.
 Avoidance  ensure that a system will never enter an unsafe
state.
Banker Algorithm in operating system.pptx
 The banker’s algorithm is a resource allocation and deadlock
avoidance algorithm
 In this each process’s maximum recourses need must be
known in advance
 It tests for safe state by simulating the allocation for
predetermined maximum possible amounts of all resources,
before deciding whether allocation should be allowed to
continue.
 Let ‘n’ be the number of processes in the system and ‘m’ be the
number of resources types.
Available:
It is a 1-d array of size ‘m’ indicating the number of available
resources of each type.
 Available[ j ] = k means there are ‘k’ instances of resource type Rj
Max:
It is a 2-d array of size ‘n*m’ that defines the maximum demand of each
process in a system.
 Max[ i, j ] = k means process Pi may request at most ‘k’ instances of
resource type Rj.
Allocation :
It is a 2-d array of size ‘n*m’ that defines the number of resources of each type
currently allocated to each process.
Allocation[i,j] = k means process Pi is currently allocated ‘k’ instances of resource
type Rj
Need :
It is a 2-d array of size ‘n*m’ that indicates the remaining resource need of each process.
Need [ i,j] = k means process Pi currently need ‘k’ instances of resource type Rj for its
execution.
Need [ i,j] = Max [i,j] – Allocation [i,j]
Allocationi specifies the resources currently allocated to process Pi and Needi specifies the
additional resources that process Pi may still request to complete its task.
1) Let Work and Finish be vectors of length ‘m’ and ‘n’ respectively.
Initialize: Work = Available
Finish[i] = false; for i=1, 2, 3, 4….n
2) Find an i such that both
a) Finish[i] = false
b) Needi <= Work
if no such i exists goto step (4)
3) Work = Work + Allocation[i]
Finish[i] = true
goto step (2)
4) if Finish [i] = true for all i
then the system is in a safe state
Let Requesti be the request array for process Pi. Requesti [j] = k means process Pi wants k
instances of resource type Rj. When a request for resources is made by process Pi, the
following actions are taken:
1) If Requesti <= Needi
Goto step (2) ; otherwise, raise an error condition, since the process has exceeded its
maximum claim.
2) If Requesti <= Available
Goto step (3); otherwise, Pi must wait, since the resources are not available.
3) Have the system pretend to have allocated the requested resources to process Pi by
modifying the state as
follows:
Available = Available – Requesti
Allocationi = Allocationi + Requesti
Needi = Needi– Requesti
2 0
- =
Calculating Need
Max [i, j] – Allocation [i, j] = Need [i, j]
0 0
3 2
Banker Algorithm in operating system.pptx
Banker Algorithm in operating system.pptx

More Related Content

DOCX
BANKER'S ALGORITHM
PPTX
Deadlock Prevention
PDF
File operations
PPTX
OSI Model - Open Systems Interconnection
PPT
Mutual exclusion and sync
PPTX
Network Layer
PDF
Process scheduling (CPU Scheduling)
DOCX
Concurrency Control Techniques
BANKER'S ALGORITHM
Deadlock Prevention
File operations
OSI Model - Open Systems Interconnection
Mutual exclusion and sync
Network Layer
Process scheduling (CPU Scheduling)
Concurrency Control Techniques

What's hot (20)

PPT
Interprocess communication (IPC) IN O.S
PPTX
Inter Process Communication
PPT
deadlock avoidance
PPTX
DeadLock in Operating-Systems
PPTX
Merge sort algorithm
PPT
Semaphores and Monitors
PDF
PPSX
CPU Scheduling algorithms
PDF
Semaphores
PDF
Deadlock Avoidance - OS
PPTX
Operating system Dead lock
PPT
Chapter 10 - File System Interface
PDF
Inter Process Communication
PPTX
Operating System Operations ppt.pptx
PPTX
cpu scheduling
PPTX
Structure of the page table
PPTX
Introduction to Unix
PPT
Input Output Operations
PDF
Deadlock in distribute system by saeed siddik
PDF
Memory management
Interprocess communication (IPC) IN O.S
Inter Process Communication
deadlock avoidance
DeadLock in Operating-Systems
Merge sort algorithm
Semaphores and Monitors
CPU Scheduling algorithms
Semaphores
Deadlock Avoidance - OS
Operating system Dead lock
Chapter 10 - File System Interface
Inter Process Communication
Operating System Operations ppt.pptx
cpu scheduling
Structure of the page table
Introduction to Unix
Input Output Operations
Deadlock in distribute system by saeed siddik
Memory management
Ad

Similar to Banker Algorithm in operating system.pptx (20)

PPTX
Methods for handling deadlock
PPT
PPT
Deadlock principles in operating systems
PPT
Chapter 7 - Deadlocks
PPT
Ch8 OS
 
PPT
PPT
Principles of Operating system and types
PPTX
Bankers algorithm
PPTX
Deadlock Algorithms 3.pptx
PPT
Module-2Deadlock.ppt
PPT
14th November - Deadlock Prevention, Avoidance.ppt
PPTX
bankers algorithm in operating system.pptx
PDF
deadlock.pdfdkfglknalkdnglqgjlejgooooo;o
PPT
Operating System
PPTX
Module 3 Deadlocks.pptx
PDF
CH07.pdf
PPTX
Deadlock - An Operating System Concept.pptx
PDF
Chapter 5(five).pdf
PPTX
OSLec14&15(Deadlocksinopratingsystem).pptx
Methods for handling deadlock
Deadlock principles in operating systems
Chapter 7 - Deadlocks
Ch8 OS
 
Principles of Operating system and types
Bankers algorithm
Deadlock Algorithms 3.pptx
Module-2Deadlock.ppt
14th November - Deadlock Prevention, Avoidance.ppt
bankers algorithm in operating system.pptx
deadlock.pdfdkfglknalkdnglqgjlejgooooo;o
Operating System
Module 3 Deadlocks.pptx
CH07.pdf
Deadlock - An Operating System Concept.pptx
Chapter 5(five).pdf
OSLec14&15(Deadlocksinopratingsystem).pptx
Ad

More from viceprincipalbfc (8)

PPTX
Introdution and objectives of Thread.pptx
PPTX
Operating System Structures and objectuve.pptx
PPTX
Disk Scheduling concept of Operating System.pptx
PPTX
3. Process Concept in operating system.pptx
PPTX
2. Operating System Structure,Services,Call, Design and Implementation.pptx
PPTX
1. Introduction to Operating System, Types.pptx
PPTX
Lecture 3 RISC-CISC characterstics and difference.pptx
PPTX
Lecture 1 - Computer Organiation Architecture - Introduction.pptx
Introdution and objectives of Thread.pptx
Operating System Structures and objectuve.pptx
Disk Scheduling concept of Operating System.pptx
3. Process Concept in operating system.pptx
2. Operating System Structure,Services,Call, Design and Implementation.pptx
1. Introduction to Operating System, Types.pptx
Lecture 3 RISC-CISC characterstics and difference.pptx
Lecture 1 - Computer Organiation Architecture - Introduction.pptx

Recently uploaded (20)

PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
Trump Administration's workforce development strategy
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
RMMM.pdf make it easy to upload and study
PDF
IGGE1 Understanding the Self1234567891011
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
UNIT III MENTAL HEALTH NURSING ASSESSMENT
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
A systematic review of self-coping strategies used by university students to ...
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
Trump Administration's workforce development strategy
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Supply Chain Operations Speaking Notes -ICLT Program
LDMMIA Reiki Yoga Finals Review Spring Summer
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Indian roads congress 037 - 2012 Flexible pavement
Practical Manual AGRO-233 Principles and Practices of Natural Farming
RMMM.pdf make it easy to upload and study
IGGE1 Understanding the Self1234567891011
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Orientation - ARALprogram of Deped to the Parents.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
A powerpoint presentation on the Revised K-10 Science Shaping Paper

Banker Algorithm in operating system.pptx

  • 2.  Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need.  Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes.  The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition. Requires that the system has some additional a priori information available.
  • 3.  When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state.  System is in safe state if there exists a safe sequence of all processes.  Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj, with j<I.  If Pi resource needs are not immediately available, then Pi can wait until all Pj have finished.  When Pj is finished, Pi can obtain needed resources, execute, return allocated resources, and terminate.  When Pi terminates, Pi+1 can obtain its needed resources, and so on.
  • 4.  If a system is in safe state  no deadlocks.  If a system is in unsafe state  possibility of deadlock.  Avoidance  ensure that a system will never enter an unsafe state.
  • 6.  The banker’s algorithm is a resource allocation and deadlock avoidance algorithm  In this each process’s maximum recourses need must be known in advance  It tests for safe state by simulating the allocation for predetermined maximum possible amounts of all resources, before deciding whether allocation should be allowed to continue.
  • 7.  Let ‘n’ be the number of processes in the system and ‘m’ be the number of resources types. Available: It is a 1-d array of size ‘m’ indicating the number of available resources of each type.  Available[ j ] = k means there are ‘k’ instances of resource type Rj
  • 8. Max: It is a 2-d array of size ‘n*m’ that defines the maximum demand of each process in a system.  Max[ i, j ] = k means process Pi may request at most ‘k’ instances of resource type Rj.
  • 9. Allocation : It is a 2-d array of size ‘n*m’ that defines the number of resources of each type currently allocated to each process. Allocation[i,j] = k means process Pi is currently allocated ‘k’ instances of resource type Rj
  • 10. Need : It is a 2-d array of size ‘n*m’ that indicates the remaining resource need of each process. Need [ i,j] = k means process Pi currently need ‘k’ instances of resource type Rj for its execution. Need [ i,j] = Max [i,j] – Allocation [i,j] Allocationi specifies the resources currently allocated to process Pi and Needi specifies the additional resources that process Pi may still request to complete its task.
  • 11. 1) Let Work and Finish be vectors of length ‘m’ and ‘n’ respectively. Initialize: Work = Available Finish[i] = false; for i=1, 2, 3, 4….n 2) Find an i such that both a) Finish[i] = false b) Needi <= Work if no such i exists goto step (4) 3) Work = Work + Allocation[i] Finish[i] = true goto step (2) 4) if Finish [i] = true for all i then the system is in a safe state
  • 12. Let Requesti be the request array for process Pi. Requesti [j] = k means process Pi wants k instances of resource type Rj. When a request for resources is made by process Pi, the following actions are taken: 1) If Requesti <= Needi Goto step (2) ; otherwise, raise an error condition, since the process has exceeded its maximum claim. 2) If Requesti <= Available Goto step (3); otherwise, Pi must wait, since the resources are not available. 3) Have the system pretend to have allocated the requested resources to process Pi by modifying the state as follows: Available = Available – Requesti Allocationi = Allocationi + Requesti Needi = Needi– Requesti
  • 13. 2 0
  • 14. - = Calculating Need Max [i, j] – Allocation [i, j] = Need [i, j] 0 0 3 2