Re: detect deadlock



Hi,

dbtouch wrote:
I use top to detect possible deadlocked process: whose threads are
deadlocked. I use two conditions:

1. all the thread are in 'S' status
2. every thread is waiting for a resource.

the conditions are neither necessary nor sufficient.
E.g. your application may block on external input or two threads may have a deadlock while others are still running.

For 2, top cannot show that the two threads are waiting for each
other's resource, even I created a deadlock situation on purpose. I
wonder if there is a better way to detect deadlock.

You have to track the dependency tree of each waiting thread. If this tree consists cyclic references, you have a deadlock.
Unfortunately it is not sufficient to track dependencies only of the threads of one process, because the dependency might involve resources of other programs or the system (file locks, accept...). And finally you may also encounter deadlocks that are distributed over the network. All you need for this is for instance an application that accesses a DBMS.

The effort depends on what you want to capture. For debugging purposes it might be sufficient to break into the debugger when a wait takes unusually long. You can analyze the situation then manually, which is usually quite fast.


Marcel
.



Relevant Pages

  • Re: How to programmatically avoid deadlock?
    ... There are four necessary conditions for deadlock to appear: ... Condition of waiting (threads hold some owned resource and wait to ... A non-blocking wait (where the thread can do other things while waiting) ...
    (comp.programming.threads)
  • Re: How to programmatically avoid deadlock?
    ... before the wait for the 'other' resource is resolved. ... splitting computation in a vat into "turns" which occur in response to ... versatile parallel programming technique helps me to ... understand that deadlock situation is fully natural, ...
    (comp.programming.threads)
  • Re: Deadlock im Recht
    ... Schön, mal wieder davon zu hören, kenn ich noch aus den Vorlesungen. ... Deadlock: ... Conditions for Resource Deadlock ... At most 1 KLT is in its CS ...
    (de.soc.recht.misc)
  • Re: Threads and Deadlocks
    ... the deadlock because either it is holding a resource other threads are waiting on or it is waiting on a resource some other thread is using and sleeping. ... The deadlock is intentionally created in the most obvious way just to see what happened; in this sense the program is correct, it does exaclty what it was meant to: ... If I can somehow trap the event that makes the ruby interpreter terminate I could obviously recover the deadlock, since blocked resources would have been constructed to be recoverable. ...
    (comp.lang.ruby)
  • Re: Prevents Events From Interrupting Events
    ... But since that's pretty obvious and since you're still asking the question, I'm assuming you don't have complete control over the events. ... it cannot move and I get a deadlock. ... then you also need to design your architecture so that you don't have one thread trying to get a resource another already has while that other thread is trying to get the resource the first thread already has. ... The delegate type does in fact make this potentially easier, since you can either create your own queue of delegates with an object array for the parameters and process it yourself, or take advantage of the Control.BeginInvokemethod to queue execution of delegates on a very specific thread. ...
    (microsoft.public.dotnet.languages.csharp)

Loading