Question

This example regarding deadlock detection was shown during one of my lectures and I have a doubt about it. The image is shown below.

For deadlock detection mechanism, why does T4 point only to T2 and not T1? Chronologically, T1 requests for the exclusive lock before T4. So shouldn't T4 point to T1 as well?

Dependency Graph

Was it helpful?

Solution

T4 is only requesting B, which is held by T2. The line represents the dependency on the resource from a requestor to a holder; the graph does not model a "queue" of waiters, that's a different problem.

To help understand the graph draw the 4 processes T1-T4. Each time a resource is granted to a process, put the letter next to it. When you realize a process needs a resource held by another process draw a line from the waiter to the holder.

So in order:

  • T1 is granted A
  • T2 is granted B exclusively, T1 requests B. Draw a line from T1 to T2.
  • T3 is granted C
  • T2 requests an exclusive lock on C which is incompatible with the shared lock held by T3. Draw a line from T2 to T3.
  • T4 requests requests an exclusive lock on B which is held by T2. Draw a line from T4 to T2.

This is not a deadlock, btw. If this helped you, please don't forget to mark this as solved; thank you.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top