• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Deadlock in distribute system by saeed siddik

Deadlock in distribute system by saeed siddik






Total Views
Views on SlideShare
Embed Views



1 Embed 1

http://www.linkedin.com 1



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Deadlock in distribute system by saeed siddik Deadlock in distribute system by saeed siddik Document Transcript

    • Distributed Deadlock Assignment No : 02Course Name: Distributed SystemsCourse 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
    • DeadlockA deadlock is a situation in which two or more competing actions are eachwaiting for the other to finish, and thus neither ever does. The result is thatboth processes hang. Deadlocks occur most commonly in multitasking andclient/server environments. Ideally, the programs that are deadlocked, orthe operating system, should resolve the deadlock, but this doesnt alwayshappen. A deadlock is also called a deadly embrace. A deadlock is a statewhere a set of processes request resources that are held by other processesin the set.Deadlock in Distributed SystemA deadlock is a fundamental problem in distributed systems. Distributeddeadlocks can occur in distributed systems when distributed transactions orconcurrency control is being used. A process may request resources in anyorder, which may not be known a priori and a process can request resourcewhile holding others. If the sequence of the allocations of resources to theprocesses 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 exclusionA resource can be held by at most one process.2. Hold and waitProcesses that already hold resources can wait for another resource.3. Non-preemptionA resource, once granted, cannot be taken away.4. Circular waitTwo or more processes are waiting for resources held by one of the otherprocesses.
    • Resource allocation can be represented by directed graphs:Deadlock is present when the graph has cycles. An example is shown inFigure 1. Figure 1: Deadlock on 4 process and 4 resources.The figure illustrates a deadlock condition between 4 processes P1,P2,P3,P4and 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 deadlocksDeadlocks in distributed systems are similar to deadlocks in centralizedsystems. In centralized systems, we have one operating system that canoversee resource allocation and know whether deadlocks are (or will be)present. With distributed processes and resources it becomes harder todetect, avoid, and prevent deadlocks.Several strategies can be used to handle deadlocks:ignore: we can ignore the problem. This is one of the most popularsolutions.detect: we can allow deadlocks to occur, then detect that we have adeadlock in the system, and then deal with the deadlockprevent: we can place constraints on resource allocation to make deadlocksimpossibleavoid: we can choose resource allocation carefully and make deadlocksimpossible. Deadlock avoidance is never used (either in distributed orcentralized systems). The problem with deadlock avoidance is that thealgorithm will need to know resource usage requirements in advance so asto schedule them properly.Centralized deadlock detectionThe centralized algorithm attempts to imitate the non-distributed algorithmby using a centralized coordinator. Each machine is responsible formaintaining its own processes and resources. The coordinator maintains theresource utilization graph for the entire system. To accomplish this, theindividual sub graphs need to be propagated to the coordinator. This can bedone by sending a message each time an arc is added or deleted.Suppose machine A has a process P0 which holds resource S and wantsresource R. Resource R is held by P1. This local graph is maintained onmachine A. Suppose that another machine B, has a process P2, which isholding resource T and wants resource S.
    • Distributed detection algorithmThe algorithm begins by sending a probe message to the processes holdingthe needed resources. The probe message consists of three numbers:1. The process that just blocked2. The process sending the message (initially the same as 1)3. The process to which it is being sent.Distributed deadlock detectionThe sample resource graph here shows only processes. Each arc passesthrough a resource, but resources have been omitted for simplicity. Someprocesses, such as 0, 1, 3, 6 are waiting for local resources. Others, such as2, 4, 5, 8 are waiting for resources on other machines. Suppose process 0requests a resource held by process 1. It constructs a probe messagecontaining (0, 0, 1) and sends it to process 1.Distributed deadlock preventionDeadlock prevention algorithms deal with designing the system in such away that deadlocks cannot occur. There are a number of techniques thatexist 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 distributedsystem with global time and atomic transactions, two other algorithms arepossible. These are based on the idea of assigning a global time stamp toeach transaction the moment it starts (no two transactions can have theexact same time stamp -- use Lamport’s algorithm or a global sequencenumber generator.