Subj : Re: deadlock avoidance To : comp.programming.threads From : doug Date : Fri May 20 2005 09:48 am "axter" wrote in message news:1116568343.493392.153930@g44g2000cwa.googlegroups.com... > Are there any good C++ methods, objects, or logic to avoid deadlocks? > > I have the following code: > http://code.axter.com/sync_ptr.h > http://code.axter.com/sync_ctrl.h > > I'm trying to figure out a way in which the smart pointer can > automatically avoid deadlocks. > > Right now I'm stuck, and I was hoping someone here could come up with > something I've overlooked, or something I'm not aware of. > > Any advice would be appreciated. > Have a google for "hierarchical locking". There are other approaches, but I think this is the most common (for now, any way). Basically, you just assign each semaphore a place in a hierarchy. When you acquire a semaphore, you must not hold any sempahores above it in the hierarchy. If you need to, you must first drop all the lower semaphores. If you find any other methods, please give us a shout! Doug .