941 Subj : Re: C++ desired features To : comp.lang.c++.moderated,comp.programming.threads From : David Schwartz Date : Wed Feb 23 2005 06:04 pm "Sergey P. Derevyago" wrote in message news:421C6859.5C3E3D08@iobox.com... > 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. That is, if it works at all. Deadlocks often result from not designing a sensible locking scheme from the beginning. Then again, the "fix" for deadlocks in programs like this always turns out to be holding locks for longer and merging locks, resulting in terrible slowness and lack of scalability. > But what we see in real life is herds of mutexes spread across the code. > "MT-aware classes" try to lock almost every method... And even more, some > "industrial-strength" PLs have the built-in mutex per every object! IMHO > there > is no excuse for this madness. Nope, none. Enforcing order has a cost, and clever programmers enforce order only when the benefits outweigh the costs. Sometimes the benefits are performance, sometimes they're simplicity of coding. The most effort should be focused on the proverbial 20% of the code that's performance-critical. (Most of that 20% should be in common libraries that you write once and used dozens of times anyway.) >> Multithreaded programming is clearly about parallel execution. But >> we'd also like to preserve program correctness in the process, which >> means we need a way to prevent threads from operating on intermediate, >> inconsistent versions of data structures that are being modified by >> other threads. > The data that really has to be modified from several threads > simultaneously > is very rare. Yes, I'm talking about properly designed applications. Exactly. This is why you should start your design with the data. The first question you should ask after "what is my program going to do" is "what data do I need to represent and manipulate it, and what types of manipulations will I need to do to it". DS [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] . 0