Subj : Re: recursive mutexes To : comp.programming.threads From : Steve Thompson Date : Wed May 18 2005 10:04 pm On Wed, 18 May 2005, David Schwartz wrote: > "Uenal Mutlu" <520001085531-0001@t-online.de> wrote in message > news:d6g7vi$ma4$04$1@news.t-online.com... > > > I would say that it is even much easier to develop a complex system > > and also much easier to maintain it by the use of recursive mutices. > > Have you ever developed and maintained a complex system? Say a project > involving at least 150,000 lines of code, at least 4 programmers, and at > least 4 released versions. I've found that it's much easier when every piece > of code knows what mutexes it holds. Absolutely agree. I have developed a multi-platform (unix/windows/vms) batch system called NBS, with over 400K lines of code. The queue manager/job scheduler portion of this package uses threads heavily. The first incarnation of the threaded version of this code (a few years ago now) used recursive mutexes, since at the time I was relatively new to pthreads and made the newbie mistake of thinking that a recursive mutex would ease the porting of the previous non-threaded version. Big mistake: recursive mutexes turn out to be a great way to initially mask design problems that ultimately lead to a rat's nest of other problems as the code evolves. It is clear that when multiple structures are being protected by a per-structure mutex, the use of recursive mutexes can be a fantastically efficient way to create deadlocks. The qmgr worked, but not very well (hangs after a few days of operation were common). All recursive mutexes are gone, the design is much cleaner as a result, the code is solid as a rock (runs for months on end), and I promise to never ever use a recursive mutex again. Honest. -steve .