SlideShare a Scribd company logo
1 of 6
Download to read offline
Distributed Deadlock
                         Assignment No : 02

Course Name: Distributed Systems
Course Code: CSE 601


                              Submitted to

                       Dr. Kazi Muheymin-Us-Sakib
                             Associate Professor
                    Institute of Information Technology,
                             University of Dhaka




                              Submitted by

                            Md. Saeed Siddik
                                 BIT 0218



                   Submission Date : November 8, 2012




                    Institute of Information Technology,
                             University of Dhaka
Deadlock

A deadlock is a situation in which two or more competing actions are each
waiting for the other to finish, and thus neither ever does. The result is that
both processes hang. Deadlocks occur most commonly in multitasking and
client/server environments. Ideally, the programs that are deadlocked, or
the operating system, should resolve the deadlock, but this doesn't always
happen. A deadlock is also called a deadly embrace. A deadlock is a state
where a set of processes request resources that are held by other processes
in the set.



Deadlock in Distributed System

A deadlock is a fundamental problem in distributed systems. Distributed
deadlocks can occur in distributed systems when distributed transactions or
concurrency control is being used. A process may request resources in any
order, which may not be known a priori and a process can request resource
while holding others. If the sequence of the allocations of resources to the
processes is not controlled, deadlocks can occur.



Conditions for Deadlock:

Four conditions have to be met for a deadlock to occur in a system:

1. Mutual exclusion

A resource can be held by at most one process.

2. Hold and wait

Processes that already hold resources can wait for another resource.

3. Non-preemption

A resource, once granted, cannot be taken away.

4. Circular wait

Two or more processes are waiting for resources held by one of the other
processes.
Resource allocation can be represented by directed graphs:

Deadlock is present when the graph has cycles. An example is shown in
Figure 1.




             Figure 1: Deadlock on 4 process and 4 resources.



The figure illustrates a deadlock condition between 4 processes P1,P2,P3,P4
and four resources: R1, R2, R3, R4.

Process P1 is holding resource R1 and wants resource R3.

Resource R3 is held by process P3 which wants resource R2.

Resource R2 is held by process P2 which wants resource R1.

Resource R1 is held by process P1 and hence we have deadlock.
Strategies to handle deadlocks

Deadlocks in distributed systems are similar to deadlocks in centralized
systems. In centralized systems, we have one operating system that can
oversee resource allocation and know whether deadlocks are (or will be)
present. With distributed processes and resources it becomes harder to
detect, avoid, and prevent deadlocks.

Several strategies can be used to handle deadlocks:

ignore: we can ignore the problem. This is one of the most popular
solutions.

detect: we can allow deadlocks to occur, then detect that we have a
deadlock in the system, and then deal with the deadlock

prevent: we can place constraints on resource allocation to make deadlocks
impossible

avoid: we can choose resource allocation carefully and make deadlocks
impossible. Deadlock avoidance is never used (either in distributed or
centralized systems). The problem with deadlock avoidance is that the
algorithm will need to know resource usage requirements in advance so as
to schedule them properly.



Centralized deadlock detection

The centralized algorithm attempts to imitate the non-distributed algorithm
by using a centralized coordinator. Each machine is responsible for
maintaining its own processes and resources. The coordinator maintains the
resource utilization graph for the entire system. To accomplish this, the
individual sub graphs need to be propagated to the coordinator. This can be
done by sending a message each time an arc is added or deleted.

Suppose machine A has a process P0 which holds resource S and wants
resource R. Resource R is held by P1. This local graph is maintained on
machine A. Suppose that another machine B, has a process P2, which is
holding resource T and wants resource S.
Distributed detection algorithm

The algorithm begins by sending a probe message to the processes holding
the needed resources. The probe message consists of three numbers:

1. The process that just blocked

2. The process sending the message (initially the same as 1)

3. The process to which it is being sent.



Distributed deadlock detection




The sample resource graph here shows only processes. Each arc passes
through a resource, but resources have been omitted for simplicity. Some
processes, such as 0, 1, 3, 6 are waiting for local resources. Others, such as
2, 4, 5, 8 are waiting for resources on other machines. Suppose process 0
requests a resource held by process 1. It constructs a probe message
containing (0, 0, 1) and sends it to process 1.



Distributed deadlock prevention

Deadlock prevention algorithms deal with designing the system in such a
way that deadlocks cannot occur. There are a number of techniques that
exist to accomplish this:

      allow processes to hold one resource at a time
      require all processes to request all resources initially and release them
       all when asking for a new one
      order all resources and require processes to acquire them in increasing
       order (making cycles impossible)
These are all rather cumbersome in practice. If we have a distributed
system with global time and atomic transactions, two other algorithms are
possible. These are based on the idea of assigning a global time stamp to
each transaction the moment it starts (no two transactions can have the
exact same time stamp -- use Lamport’s algorithm or a global sequence
number generator.

More Related Content

What's hot

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating systemAli Haider
 
Remote invocation
Remote invocationRemote invocation
Remote invocationishapadhy
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 
Distributed process and scheduling
Distributed process and scheduling Distributed process and scheduling
Distributed process and scheduling SHATHAN
 
distributed shared memory
 distributed shared memory distributed shared memory
distributed shared memoryAshish Kumar
 
Processes and Processors in Distributed Systems
Processes and Processors in Distributed SystemsProcesses and Processors in Distributed Systems
Processes and Processors in Distributed SystemsDr Sandeep Kumar Poonia
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed systemSunita Sahu
 
Synchronization in distributed computing
Synchronization in distributed computingSynchronization in distributed computing
Synchronization in distributed computingSVijaylakshmi
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYdeadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYअनिकेत चौधरी
 
Deadlock detection
Deadlock detectionDeadlock detection
Deadlock detectionNadia Nahar
 
Deadlock management
Deadlock managementDeadlock management
Deadlock managementAhmed kasim
 
Synchronization Pradeep K Sinha
Synchronization Pradeep K SinhaSynchronization Pradeep K Sinha
Synchronization Pradeep K SinhaJawwad Rafiq
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corbaMayuresh Wadekar
 
Processor allocation in Distributed Systems
Processor allocation in Distributed SystemsProcessor allocation in Distributed Systems
Processor allocation in Distributed SystemsRitu Ranjan Shrivastwa
 

What's hot (20)

Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
Remote invocation
Remote invocationRemote invocation
Remote invocation
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
Distributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithmsDistributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithms
 
Distributed process and scheduling
Distributed process and scheduling Distributed process and scheduling
Distributed process and scheduling
 
distributed shared memory
 distributed shared memory distributed shared memory
distributed shared memory
 
Processes and Processors in Distributed Systems
Processes and Processors in Distributed SystemsProcesses and Processors in Distributed Systems
Processes and Processors in Distributed Systems
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency control
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
 
Synchronization in distributed computing
Synchronization in distributed computingSynchronization in distributed computing
Synchronization in distributed computing
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYdeadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
 
Deadlock detection
Deadlock detectionDeadlock detection
Deadlock detection
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
 
Deadlock management
Deadlock managementDeadlock management
Deadlock management
 
Synchronization Pradeep K Sinha
Synchronization Pradeep K SinhaSynchronization Pradeep K Sinha
Synchronization Pradeep K Sinha
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corba
 
Processor allocation in Distributed Systems
Processor allocation in Distributed SystemsProcessor allocation in Distributed Systems
Processor allocation in Distributed Systems
 

Viewers also liked

Deadlock detection in distributed systems
Deadlock detection in distributed systemsDeadlock detection in distributed systems
Deadlock detection in distributed systemsReza Ramezani
 
Intro to Deadlocks
Intro to DeadlocksIntro to Deadlocks
Intro to Deadlockslionpeal
 
Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock DetectionPOOJA MEHTA
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and propertiesChetan Mahawar
 
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
 
Transaction management
Transaction managementTransaction management
Transaction managementrenuka_a
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
Distributed databases,types of database
Distributed databases,types of databaseDistributed databases,types of database
Distributed databases,types of databaseBoomadevi Shanmugam
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed SystemsRupsee
 
Google Fusion Tables - Silicon Valley CodeCamp 2010
Google Fusion Tables - Silicon Valley CodeCamp 2010Google Fusion Tables - Silicon Valley CodeCamp 2010
Google Fusion Tables - Silicon Valley CodeCamp 2010Kathryn Brisbin
 
Electronic delivery of services initiative
Electronic delivery of services initiativeElectronic delivery of services initiative
Electronic delivery of services initiativepcmcindia
 
Connect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instanceConnect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instanceSaeed Siddik
 
Ict enabled municipal initiative
Ict enabled municipal initiativeIct enabled municipal initiative
Ict enabled municipal initiativepcmcindia
 
Comparative analysis on different DES model
Comparative analysis on different DES modelComparative analysis on different DES model
Comparative analysis on different DES modelSaeed Siddik
 

Viewers also liked (20)

Deadlock detection in distributed systems
Deadlock detection in distributed systemsDeadlock detection in distributed systems
Deadlock detection in distributed systems
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Intro to Deadlocks
Intro to DeadlocksIntro to Deadlocks
Intro to Deadlocks
 
Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock Detection
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
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
 
Dbms acid
Dbms acidDbms acid
Dbms acid
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Deadlock
DeadlockDeadlock
Deadlock
 
Transaction management
Transaction managementTransaction management
Transaction management
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
Distributed databases,types of database
Distributed databases,types of databaseDistributed databases,types of database
Distributed databases,types of database
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
Google Fusion Tables - Silicon Valley CodeCamp 2010
Google Fusion Tables - Silicon Valley CodeCamp 2010Google Fusion Tables - Silicon Valley CodeCamp 2010
Google Fusion Tables - Silicon Valley CodeCamp 2010
 
3 transaction
3 transaction3 transaction
3 transaction
 
Electronic delivery of services initiative
Electronic delivery of services initiativeElectronic delivery of services initiative
Electronic delivery of services initiative
 
Connect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instanceConnect dell equallogic storage to linux instance
Connect dell equallogic storage to linux instance
 
Ict enabled municipal initiative
Ict enabled municipal initiativeIct enabled municipal initiative
Ict enabled municipal initiative
 
Comparative analysis on different DES model
Comparative analysis on different DES modelComparative analysis on different DES model
Comparative analysis on different DES model
 

Similar to Deadlock in distribute system by saeed siddik

Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemEktaVaswani2
 
DEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxDEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxPugalenthiSomasundar
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systemsjamunaashok
 
Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)WajeehaBaig
 
Improved Deadlock Prevention Algorithms in Distributed Systems
Improved Deadlock Prevention Algorithms in Distributed SystemsImproved Deadlock Prevention Algorithms in Distributed Systems
Improved Deadlock Prevention Algorithms in Distributed SystemsIJEACS
 
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
 
Distributed systems_important 2marks.docx
Distributed systems_important 2marks.docxDistributed systems_important 2marks.docx
Distributed systems_important 2marks.docx20TUCS251VIJAYASHARA
 
3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptxsvulasal
 
Chapter 03
Chapter 03Chapter 03
Chapter 03 Google
 

Similar to Deadlock in distribute system by saeed siddik (20)

Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
DEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxDEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptx
 
operating system
operating systemoperating system
operating system
 
operating system
operating systemoperating system
operating system
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systems
 
Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Module3
Module3Module3
Module3
 
Improved Deadlock Prevention Algorithms in Distributed Systems
Improved Deadlock Prevention Algorithms in Distributed SystemsImproved Deadlock Prevention Algorithms in Distributed Systems
Improved Deadlock Prevention Algorithms in Distributed Systems
 
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...
 
Distributed systems_important 2marks.docx
Distributed systems_important 2marks.docxDistributed systems_important 2marks.docx
Distributed systems_important 2marks.docx
 
Process coordination
Process coordinationProcess coordination
Process coordination
 
Deadlock
DeadlockDeadlock
Deadlock
 
Operating system Deadlock
Operating system DeadlockOperating system Deadlock
Operating system Deadlock
 
3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 

Deadlock in distribute system by saeed siddik

  • 1. Distributed Deadlock Assignment No : 02 Course Name: Distributed Systems Course Code: CSE 601 Submitted to Dr. Kazi Muheymin-Us-Sakib Associate Professor Institute of Information Technology, University of Dhaka Submitted by Md. Saeed Siddik BIT 0218 Submission Date : November 8, 2012 Institute of Information Technology, University of Dhaka
  • 2. Deadlock A deadlock is a situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does. The result is that both processes hang. Deadlocks occur most commonly in multitasking and client/server environments. Ideally, the programs that are deadlocked, or the operating system, should resolve the deadlock, but this doesn't always happen. A deadlock is also called a deadly embrace. A deadlock is a state where a set of processes request resources that are held by other processes in the set. Deadlock in Distributed System A deadlock is a fundamental problem in distributed systems. Distributed deadlocks can occur in distributed systems when distributed transactions or concurrency control is being used. A process may request resources in any order, which may not be known a priori and a process can request resource while holding others. If the sequence of the allocations of resources to the processes is not controlled, deadlocks can occur. Conditions for Deadlock: Four conditions have to be met for a deadlock to occur in a system: 1. Mutual exclusion A resource can be held by at most one process. 2. Hold and wait Processes that already hold resources can wait for another resource. 3. Non-preemption A resource, once granted, cannot be taken away. 4. Circular wait Two or more processes are waiting for resources held by one of the other processes.
  • 3. Resource allocation can be represented by directed graphs: Deadlock is present when the graph has cycles. An example is shown in Figure 1. Figure 1: Deadlock on 4 process and 4 resources. The figure illustrates a deadlock condition between 4 processes P1,P2,P3,P4 and four resources: R1, R2, R3, R4. Process P1 is holding resource R1 and wants resource R3. Resource R3 is held by process P3 which wants resource R2. Resource R2 is held by process P2 which wants resource R1. Resource R1 is held by process P1 and hence we have deadlock.
  • 4. Strategies to handle deadlocks Deadlocks in distributed systems are similar to deadlocks in centralized systems. In centralized systems, we have one operating system that can oversee resource allocation and know whether deadlocks are (or will be) present. With distributed processes and resources it becomes harder to detect, avoid, and prevent deadlocks. Several strategies can be used to handle deadlocks: ignore: we can ignore the problem. This is one of the most popular solutions. detect: we can allow deadlocks to occur, then detect that we have a deadlock in the system, and then deal with the deadlock prevent: we can place constraints on resource allocation to make deadlocks impossible avoid: we can choose resource allocation carefully and make deadlocks impossible. Deadlock avoidance is never used (either in distributed or centralized systems). The problem with deadlock avoidance is that the algorithm will need to know resource usage requirements in advance so as to schedule them properly. Centralized deadlock detection The centralized algorithm attempts to imitate the non-distributed algorithm by using a centralized coordinator. Each machine is responsible for maintaining its own processes and resources. The coordinator maintains the resource utilization graph for the entire system. To accomplish this, the individual sub graphs need to be propagated to the coordinator. This can be done by sending a message each time an arc is added or deleted. Suppose machine A has a process P0 which holds resource S and wants resource R. Resource R is held by P1. This local graph is maintained on machine A. Suppose that another machine B, has a process P2, which is holding resource T and wants resource S.
  • 5. Distributed detection algorithm The algorithm begins by sending a probe message to the processes holding the needed resources. The probe message consists of three numbers: 1. The process that just blocked 2. The process sending the message (initially the same as 1) 3. The process to which it is being sent. Distributed deadlock detection The sample resource graph here shows only processes. Each arc passes through a resource, but resources have been omitted for simplicity. Some processes, such as 0, 1, 3, 6 are waiting for local resources. Others, such as 2, 4, 5, 8 are waiting for resources on other machines. Suppose process 0 requests a resource held by process 1. It constructs a probe message containing (0, 0, 1) and sends it to process 1. Distributed deadlock prevention Deadlock prevention algorithms deal with designing the system in such a way that deadlocks cannot occur. There are a number of techniques that exist to accomplish this:  allow processes to hold one resource at a time  require all processes to request all resources initially and release them all when asking for a new one  order all resources and require processes to acquire them in increasing order (making cycles impossible)
  • 6. These are all rather cumbersome in practice. If we have a distributed system with global time and atomic transactions, two other algorithms are possible. These are based on the idea of assigning a global time stamp to each transaction the moment it starts (no two transactions can have the exact same time stamp -- use Lamport’s algorithm or a global sequence number generator.