Subj : Re: C++ desired features To : comp.lang.c++.moderated,comp.programming.threads From : Joe Seigh Date : Thu Feb 24 2005 04:20 pm On 23 Feb 2005 16:44:19 -0500, Sergey P. Derevyago wrote: > Hans Boehm wrote: >> > Some people think that MT is about locking. While the original idea >> > is MT is about parallel simultaneous execution. >> > >> Could you expand on this? >> > Please let me cite a David Butenhof's posting: "multithreading is defined by > an application design that ALLOWS FOR concurrent or simultaneous execution". > Obviously, (excessive) locking does NOT allow for simultaneous execution. > > A lot of people are used to write old good ST code and "add some locks to > make it thread-safe" _afterwards_. The realworld result is always frustrating: > the application is terribly slow and doesn't scale. > Sure, we need some synchronization primitives (such as mutexes) to implement > inter-thread communication. As a rule, thoroughly designed MT application is a > set of fully independent threads which communicate via the message queues. The > synchronization primitives are used inside these queues and virtually no locks > are supposed outside the queues. Multithreading usage patterns tend to fall into producer/consumer or reader/writer patterns. Message passing works well with the former but doesn't work well with the latter. Mutexes don't scale well with the latter by definition. rwlocks don't scale so well either. Lock-free stuff seems to do quite well. You can crank up the contention level to 11 which will kill mutex and rwlock based solutions and the lock-free stuff doesn't even seem to breath heavy. -- Joe Seigh [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] .