SlideShare a Scribd company logo
1 of 17
D E A D L O C K
&
B A N K E R ’ S A L G O R I T H M
O P E R AT I N G S Y S T E M ( C S E - 3 2 3 )
WHAT IS DEADLOCK!!??
Deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource acquired by some other process. In a
multiprogramming system, numerous processes get competed for a finite number of
resources. Any process requests resources, and as the resources aren't available at that
time, the process goes into a waiting state. At times, a waiting process is not at all able
again to change its state as other waiting processes detain the resources it has requested.
So in this condition, a deadlock is appeared.
In the operating system, multiple resources are used by process in three different ways,
such as –
 Requests for resource
 Use this resource
 Free this resource after completing task.
WHAT IS DEADLOCK!!??
In the diagram above, the process 1 has resource 1 and needs to acquire resource 2.
Similarly process 2 has resource 2 and needs to acquire resource 1. Process 1 and
process 2 are in deadlock as each of them needs the other’s resource to complete their
execution but neither of them is willing to relinquish their resources.
DEADLOCK CHARACTERIZATION
A deadlock state can occur when the following four circumstances hold simultaneously
within a system:
Mutual exclusion: At least there should be one resource that has to be held in a non-
sharable manner. Only a single process at a time can utilize the resource. If other
process demands that resource, the requesting process must be postponed until the
resource gets released.
Hold and wait: A job must be holding at least one single resource and waiting to
obtain supplementary resources which are currently being held by several other
processes.
DEADLOCK CHARACTERIZATION
A deadlock state can occur when the following four circumstances hold simultaneously
within a system:
No preemption: In which one process cannot take the resources of other processes by
by force. A resource cannot be taken from a process unless the process releases the
resource
Circular wait: The circular wait situation implies the hold-and-wait state or condition,
and hence all the four conditions are not completely independent. They are
interconnected among each other.
There is some basic facts regarding a system’s deadlock issue. Those are,
• If all the 4 characterization occurs simultaneously then there will be deadlock present
the system.
• As a result, if the graph contains no cycle then there will be no deadlock present in the
system.
• But when a graph contains a cycle, then there can be two conditions present at the
system,
– If there is only one instance present per resources then the deadlock will be present.
– But if there are more than one instance per resources then there will be not deadlock.
• The state of the system informs that if resources
are allocated to different processes then
the system undergoes deadlock or not.
If the system can allocate resources to the
process in such a way that it can avoid deadlock.
Then the system is in a safe state. If the system can’t allocate resources to the process
safely, then the system is in an unsafe state. Unsafe state system may lead to deadlock
but not always.
HANDLING DEADLOCKS
Deadlock Prevention:
Preventing deadlocks by constraining how requests for resources can be made in the
system and how they are handled (system design). The goal is to ensure that at least
of the necessary conditions(Mutual exclusion, Hold and wait, No preemption, Circular
wait) for deadlock can never hold.
Deadlock Avoidance:
The system dynamically considers every request and decides whether it is safe to grant
at this point. The system requires additional apriori information regarding the overall
potential use of each resource for each process.. Allows more concurrency.
Deadlock Detection:
Always grant resource request when possible. Periodically check for deadlocks. If a
deadlock exists, recover from it.
Ignore the problem...
AVOIDANCE ALGORITHMS
Resource Allocation
Graph
Banker’s Algorithm
Single instance of a resource type
Multiple instance of a resource type
BANKER’S ALGORITHM
It is a banker algorithm used to avoid deadlock
and allocate resources safely to each process
in the computer system. The 'S-State’ or the
safe state examines all possible tests or
activities before deciding whether the
allocation should be allowed to each process.
It also helps the operating system to
successfully share the resources between all
the processes. The banker's algorithm is
named because it checks whether a person
should be sanctioned a loan amount or not to
help the bank system safely simulate allocation
resources.
TERMS
In order to implement this algorithm, we need to know about three
things.
[MAX]
[ALLOCATED]
[AVAILABLE]
How much each process can request for each resource in the
system.
How much each process is currently holding each resource in a
system.
The number of each resource currently available in the system.
TERMS
If n is the number of processes, and m is the number of each type of resource used in a computer
system,
Available: It is an array of length 'm' that defines each type of resource available in the system. When
Available[j] = K, means that 'K' instances of Resources type R[j] are available in the system.
Max: It is a [n x m] matrix that indicates each process P[i] can store the maximum number of resources
resources
R[j] (each type) in a system.
Allocation: It is a matrix of m x n orders that indicates the type of resources currently allocated to each
process in the system. When Allocation [i, j] = K, it means that process P[i] is currently allocated K
instances of Resources type R[j] in the system.
Need: It is an M x N matrix sequence representing the number of remaining resources for each process.
process. When the Need[i] [j] = k, then process P[i] may require K more instances of resources type Rj to
complete the assigned work.
Nedd[i][j] = Max[i][j] - Allocation[i][j].
Finish: It is the vector of the order m. It includes a Boolean value (true/false) indicating whether the
process has been allocated to the requested resources, and all resources have been released after
EXAMPLE
Process Allocation MAX AVAILABLE
A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2
P2 2 0 0 3 2 2
P3 3 0 2 9 0 2
P4 2 1 1 2 2 2
P5 0 0 2 4 3 3
NEED
(max-allocation)
A B C
7 4 3
1 2 2
6 0 0
0 1 1
4 3 1
EXAMPLE (CONT.)
Available Resources of A, B and C are 3, 3, and 2.
Now we check if each type of resource request is available for each process. So, among all the
processes, process 2 follows the condition.
 For Process P2:
Need <= Available
1, 2, 2 <= 3, 3, 2; condition TRUE
So, Available Resources = 3,3,2 – 1,2,2 = 2,1,2
 After the process 2 is complete,
New available resources: Available + Allocation(With the allocation resources from start)
= 2,1,2 + 1,2,2 + 2, 0,0
= 5,3,2
Now, in the same way we will look for other processed which satisfies this condition.
 For Process P4:
Need <= Available
0,1,1<= 5,3,2condition; TRUE
So, Available Resources = 5,3,2 – 0,1,1 = 5,2,1
 After the process 4 is complete,
New available resources: Available + Allocation(With the allocation resources from start)
= 5,2,1 + 0,1,1 + 2, 1,1
= 7,4,3
P2 1 2 2
NEED
P4 0 1 1
NEED
EXAMPLE (CONT..)
Available Resources of A, B and C are 3, 3, and 2.
 For Process P5:
Need <= Available
4,3,1<= 7, 4, 3; condition TRUE
So, Available Resources = 7,4,3 – 4,3,1 = 3,1,2
 After the process 5 is complete,
New available resources: Available + Allocation(With the allocation resources from start)
= 3,1,2 + 4,3,1 + 0,0,2
= 7,4,5
Now, in the same way we will look for other processed which satisfies this condition.
 For Process P1:
Need <= Available
7,4,3<= 7,4,5; condition TRUE
So, Available Resources = 7,4,5 – 7,4,3 = 0,0,2
 After the process 4 is complete,
New available resources: Available + Allocation(With the allocation resources from start)
= 0,0,2 + 7,4,3 + 0, 1,0
= 7,5,5
P5 1 2 2
NEED
P4 0 1 1
NEED
EXAMPLE (CONT..)
Available Resources of A, B and C are 3, 3, and 2.
 For Process P3:
Need <= Available
6,0,0 <= 7, 5, 5; condition TRUE
So, Available Resources = 7,5,5 – 6,0,0 = 1,5,5
 After the process 5 is complete,
New available resources: Available + Allocation(With the allocation resources from start)
= 1,5,5 + 6,0,0 + 3,0,2
= 10,5, 7
P3 6 0 0
NEED
Hence, we execute the banker's algorithm to find the safe state and the safe
sequence like
P2, P4, P5, P1 and P3.
ADVANTAGES
 It contains various resources that meet the requirements of each process.
 Each process should provide information to the operating system for upcoming resource requests,
the number of resources, and how long the resources will be held.
 It helps the operating system manage and control process requests for each type of resource in the
computer system.
 The algorithm has a Max resource attribute that represents indicates each process can hold the
maximum number of resources in a system.
DISADVANTAGES
X It requires a fixed number of processes, and no additional processes can be started in the system
while executing the process.
X The algorithm does no longer allows the processes to exchange its maximum needs while
processing its tasks.
X Each process has to know and state their maximum resource requirement in advance for the
system.
X The number of resource requests can be granted in a finite time, but the time limit for allocating
the resources is one year.
THANK YOU
M D . A N I S U R R A H M A N
1 9 2 - 1 5 - 2 8 2 5 ( P C - B )

More Related Content

What's hot

15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMSkoolkampus
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMSMegha Patel
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidancewahab13
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbiansaad symbian
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocksA. S. M. Shafi
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systemsjamunaashok
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSKumar Pritam
 
Validation based protocol
Validation based protocolValidation based protocol
Validation based protocolBBDITM LUCKNOW
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMSkoolkampus
 
Transaction Properties in database | ACID Properties
Transaction Properties in database | ACID PropertiesTransaction Properties in database | ACID Properties
Transaction Properties in database | ACID Propertiesnomanbarki
 

What's hot (20)

15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
BANKER'S ALGORITHM
BANKER'S ALGORITHMBANKER'S ALGORITHM
BANKER'S ALGORITHM
 
Shadow paging
Shadow pagingShadow paging
Shadow paging
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbian
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocks
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systems
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Validation based protocol
Validation based protocolValidation based protocol
Validation based protocol
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
Transaction Properties in database | ACID Properties
Transaction Properties in database | ACID PropertiesTransaction Properties in database | ACID Properties
Transaction Properties in database | ACID Properties
 

Similar to Deadlock and Banking Algorithm

Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.pptKAnurag2
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptxshreesha16
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlocksangrampatil81
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OSC.U
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxssusere16bd9
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Wakil Kumar
 
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxosvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxBhaskar271887
 

Similar to Deadlock and Banking Algorithm (20)

Deadlock
DeadlockDeadlock
Deadlock
 
Os unit 4
Os unit 4Os unit 4
Os unit 4
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
Bankers
BankersBankers
Bankers
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
 
Deadlock
DeadlockDeadlock
Deadlock
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OS
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
 
Module3
Module3Module3
Module3
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxosvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 

More from MD.ANISUR RAHMAN

More from MD.ANISUR RAHMAN (6)

Explainable Ai.pdf
Explainable Ai.pdfExplainable Ai.pdf
Explainable Ai.pdf
 
IOT and its communication models and protocols.pdf
IOT and its communication models and protocols.pdfIOT and its communication models and protocols.pdf
IOT and its communication models and protocols.pdf
 
Ethics in Computing.pptx
Ethics in Computing.pptxEthics in Computing.pptx
Ethics in Computing.pptx
 
A day in the life of a Web Request
A day in the life of a Web RequestA day in the life of a Web Request
A day in the life of a Web Request
 
Oop
OopOop
Oop
 
Zener diode
Zener diodeZener diode
Zener diode
 

Recently uploaded

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 

Recently uploaded (20)

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 

Deadlock and Banking Algorithm

  • 1. D E A D L O C K & B A N K E R ’ S A L G O R I T H M O P E R AT I N G S Y S T E M ( C S E - 3 2 3 )
  • 2. WHAT IS DEADLOCK!!?? Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. In a multiprogramming system, numerous processes get competed for a finite number of resources. Any process requests resources, and as the resources aren't available at that time, the process goes into a waiting state. At times, a waiting process is not at all able again to change its state as other waiting processes detain the resources it has requested. So in this condition, a deadlock is appeared. In the operating system, multiple resources are used by process in three different ways, such as –  Requests for resource  Use this resource  Free this resource after completing task.
  • 3. WHAT IS DEADLOCK!!?? In the diagram above, the process 1 has resource 1 and needs to acquire resource 2. Similarly process 2 has resource 2 and needs to acquire resource 1. Process 1 and process 2 are in deadlock as each of them needs the other’s resource to complete their execution but neither of them is willing to relinquish their resources.
  • 4. DEADLOCK CHARACTERIZATION A deadlock state can occur when the following four circumstances hold simultaneously within a system: Mutual exclusion: At least there should be one resource that has to be held in a non- sharable manner. Only a single process at a time can utilize the resource. If other process demands that resource, the requesting process must be postponed until the resource gets released. Hold and wait: A job must be holding at least one single resource and waiting to obtain supplementary resources which are currently being held by several other processes.
  • 5. DEADLOCK CHARACTERIZATION A deadlock state can occur when the following four circumstances hold simultaneously within a system: No preemption: In which one process cannot take the resources of other processes by by force. A resource cannot be taken from a process unless the process releases the resource Circular wait: The circular wait situation implies the hold-and-wait state or condition, and hence all the four conditions are not completely independent. They are interconnected among each other.
  • 6. There is some basic facts regarding a system’s deadlock issue. Those are, • If all the 4 characterization occurs simultaneously then there will be deadlock present the system. • As a result, if the graph contains no cycle then there will be no deadlock present in the system. • But when a graph contains a cycle, then there can be two conditions present at the system, – If there is only one instance present per resources then the deadlock will be present. – But if there are more than one instance per resources then there will be not deadlock. • The state of the system informs that if resources are allocated to different processes then the system undergoes deadlock or not. If the system can allocate resources to the process in such a way that it can avoid deadlock. Then the system is in a safe state. If the system can’t allocate resources to the process safely, then the system is in an unsafe state. Unsafe state system may lead to deadlock but not always.
  • 7. HANDLING DEADLOCKS Deadlock Prevention: Preventing deadlocks by constraining how requests for resources can be made in the system and how they are handled (system design). The goal is to ensure that at least of the necessary conditions(Mutual exclusion, Hold and wait, No preemption, Circular wait) for deadlock can never hold. Deadlock Avoidance: The system dynamically considers every request and decides whether it is safe to grant at this point. The system requires additional apriori information regarding the overall potential use of each resource for each process.. Allows more concurrency. Deadlock Detection: Always grant resource request when possible. Periodically check for deadlocks. If a deadlock exists, recover from it. Ignore the problem...
  • 8. AVOIDANCE ALGORITHMS Resource Allocation Graph Banker’s Algorithm Single instance of a resource type Multiple instance of a resource type
  • 9. BANKER’S ALGORITHM It is a banker algorithm used to avoid deadlock and allocate resources safely to each process in the computer system. The 'S-State’ or the safe state examines all possible tests or activities before deciding whether the allocation should be allowed to each process. It also helps the operating system to successfully share the resources between all the processes. The banker's algorithm is named because it checks whether a person should be sanctioned a loan amount or not to help the bank system safely simulate allocation resources.
  • 10. TERMS In order to implement this algorithm, we need to know about three things. [MAX] [ALLOCATED] [AVAILABLE] How much each process can request for each resource in the system. How much each process is currently holding each resource in a system. The number of each resource currently available in the system.
  • 11. TERMS If n is the number of processes, and m is the number of each type of resource used in a computer system, Available: It is an array of length 'm' that defines each type of resource available in the system. When Available[j] = K, means that 'K' instances of Resources type R[j] are available in the system. Max: It is a [n x m] matrix that indicates each process P[i] can store the maximum number of resources resources R[j] (each type) in a system. Allocation: It is a matrix of m x n orders that indicates the type of resources currently allocated to each process in the system. When Allocation [i, j] = K, it means that process P[i] is currently allocated K instances of Resources type R[j] in the system. Need: It is an M x N matrix sequence representing the number of remaining resources for each process. process. When the Need[i] [j] = k, then process P[i] may require K more instances of resources type Rj to complete the assigned work. Nedd[i][j] = Max[i][j] - Allocation[i][j]. Finish: It is the vector of the order m. It includes a Boolean value (true/false) indicating whether the process has been allocated to the requested resources, and all resources have been released after
  • 12. EXAMPLE Process Allocation MAX AVAILABLE A B C A B C A B C P1 0 1 0 7 5 3 3 3 2 P2 2 0 0 3 2 2 P3 3 0 2 9 0 2 P4 2 1 1 2 2 2 P5 0 0 2 4 3 3 NEED (max-allocation) A B C 7 4 3 1 2 2 6 0 0 0 1 1 4 3 1
  • 13. EXAMPLE (CONT.) Available Resources of A, B and C are 3, 3, and 2. Now we check if each type of resource request is available for each process. So, among all the processes, process 2 follows the condition.  For Process P2: Need <= Available 1, 2, 2 <= 3, 3, 2; condition TRUE So, Available Resources = 3,3,2 – 1,2,2 = 2,1,2  After the process 2 is complete, New available resources: Available + Allocation(With the allocation resources from start) = 2,1,2 + 1,2,2 + 2, 0,0 = 5,3,2 Now, in the same way we will look for other processed which satisfies this condition.  For Process P4: Need <= Available 0,1,1<= 5,3,2condition; TRUE So, Available Resources = 5,3,2 – 0,1,1 = 5,2,1  After the process 4 is complete, New available resources: Available + Allocation(With the allocation resources from start) = 5,2,1 + 0,1,1 + 2, 1,1 = 7,4,3 P2 1 2 2 NEED P4 0 1 1 NEED
  • 14. EXAMPLE (CONT..) Available Resources of A, B and C are 3, 3, and 2.  For Process P5: Need <= Available 4,3,1<= 7, 4, 3; condition TRUE So, Available Resources = 7,4,3 – 4,3,1 = 3,1,2  After the process 5 is complete, New available resources: Available + Allocation(With the allocation resources from start) = 3,1,2 + 4,3,1 + 0,0,2 = 7,4,5 Now, in the same way we will look for other processed which satisfies this condition.  For Process P1: Need <= Available 7,4,3<= 7,4,5; condition TRUE So, Available Resources = 7,4,5 – 7,4,3 = 0,0,2  After the process 4 is complete, New available resources: Available + Allocation(With the allocation resources from start) = 0,0,2 + 7,4,3 + 0, 1,0 = 7,5,5 P5 1 2 2 NEED P4 0 1 1 NEED
  • 15. EXAMPLE (CONT..) Available Resources of A, B and C are 3, 3, and 2.  For Process P3: Need <= Available 6,0,0 <= 7, 5, 5; condition TRUE So, Available Resources = 7,5,5 – 6,0,0 = 1,5,5  After the process 5 is complete, New available resources: Available + Allocation(With the allocation resources from start) = 1,5,5 + 6,0,0 + 3,0,2 = 10,5, 7 P3 6 0 0 NEED Hence, we execute the banker's algorithm to find the safe state and the safe sequence like P2, P4, P5, P1 and P3.
  • 16. ADVANTAGES  It contains various resources that meet the requirements of each process.  Each process should provide information to the operating system for upcoming resource requests, the number of resources, and how long the resources will be held.  It helps the operating system manage and control process requests for each type of resource in the computer system.  The algorithm has a Max resource attribute that represents indicates each process can hold the maximum number of resources in a system. DISADVANTAGES X It requires a fixed number of processes, and no additional processes can be started in the system while executing the process. X The algorithm does no longer allows the processes to exchange its maximum needs while processing its tasks. X Each process has to know and state their maximum resource requirement in advance for the system. X The number of resource requests can be granted in a finite time, but the time limit for allocating the resources is one year.
  • 17. THANK YOU M D . A N I S U R R A H M A N 1 9 2 - 1 5 - 2 8 2 5 ( P C - B )