Avoiding deadlocks in concurrent programming

Neil Hodgson nyamatongwe+thunder at gmail.com
Wed Jun 22 21:05:50 EDT 2005


Eloff:

> So I think you would need multiple locks so clients only acquire what
> they need. This would let multiple threads access the data at once. But
> now I have to deal with deadlocks since clients will usually acquire a
> resource and then block acquiring another. It is very likely that one
> client locks A, another locks B, then the guy with B waits for A and
> the guy with A waits for B. Worse yet the backup thread will go around
> trying to lock everything and will no doubt deadlock everybody.

    The classic way to avoid lock cycles is to establish an order and 
require that locks only be acquired in that order. There is an OK 
introduction to deadlock on the wikipedia:
http://en.wikipedia.org/wiki/Deadlock

    Neil



More information about the Python-list mailing list