What is deadlock?

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

  1. coderzone

    coderzone Super Moderator

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

    shabbir Administrator Staff Member

    Jul 12, 2004
    Likes Received:
    Trophy Points:
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice