Re: How to programmatically avoid deadlock?



Vladimir Frolov wrote:
youpak wrote:

How to programmatically avoid deadlock?

Igor Odintcov wrote about it in his book "Professional programming.
System approach".
Here is free translation from russian:

There are four necessary conditions for deadlock to appear:

1. Condition of mutal execution (threads require exclusive resource
ownership).
2. Condition of waiting (threads hold some owned resource and wait to
own other one).

Note that this means a blocking wait, where the thread suspends until
the wait finishes.

A non-blocking wait (where the thread can do other things while waiting)
does not lead to deadlock. This is the approach used by event-loop
concurrency, as explained in Mark Miller's thesis that I referenced in
my other reply.

3. Condition of undistributed resources (resource cannot be taken away
while it will not be released by owner thread).
4. Condition of cycled waiting (There are circle of threads where one
thread holds one or more resources which is required by next one).

--
David Hopwood <david.nospam.hopwood@xxxxxxxxxxxxxxxx>
.



Relevant Pages

  • Re: Am I using ThreadPool the right way?
    ... It is possible to debug deadlocks and other threading issues in the Express version, but it's not something I'd recommend for someone unfamiliar with the general techniques of dealing with thread issues in the first place, since Express doesn't provide any direct way to get at the individual threads in the debugger. ... You'll be looking for threads that are stopped on a statement that waits for some resource, to identify which threads are involved in the deadlock and why they are waiting. ...
    (microsoft.public.dotnet.languages.csharp)
  • 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: detect deadlock
    ... E.g. your application may block on external input or two threads may have a deadlock while others are still running. ... other's resource, even I created a deadlock situation on purpose. ... You have to track the dependency tree of each waiting thread. ... 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. ...
    (comp.programming.threads)
  • detect deadlock
    ... I use top to detect possible deadlocked process: ... top cannot show that the two threads are waiting for each ... other's resource, even I created a deadlock situation on purpose. ...
    (comp.programming.threads)
  • deadlock detection
    ... I use top to detect possible deadlocked process: ... top cannot show that the two threads are waiting for each ... other's resource, even I created a deadlock situation on purpose. ...
    (comp.os.linux.development.apps)

Loading