1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What is deadlock?

Discussion in 'Database' started by coderzone, May 25, 2005.

  1. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    What is deadlock? How can it be avoided? How can it be resolved once it occurs?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    Deadlock :- This is an inter-blocking that occurs when two processes want to access at shared variables mutually locked. For example, let A and B two locks and P1 and P2 two processes: P1: lock A P2: lock B P1: lock B (so P1 is blocked by P2) P2: lock A (so P2 is blocked by P1) Process P1 is blocked because it is waiting for the unlocking of B variable by P2. However P2 also needs the A variable to finish its computation and free B. So we have a deadlock.

    It can avoided by one of the following options
    1. All the resources are allocated to a process when it starts and cannot request for new resources.
    2. When requesting for more resource the other resources cannot be held up by any processes.
    3. Avoid the cyclic request of resources in a wait for graph.

    You can resolve cycle deadlocks by killing the cheapest process, the one that acquired its lock last or locked for the shortest amount of time.
     

Share This Page