Re: C++ Threads, what's the status quo?
Le Chaud Lapin wrote:
Francis Glassborow wrote:
The only deduction I can make from this is that you believe C++ should
be dead and buried. C++ without threading will be tantamount to useless
by the end of this decade. Even mobile phones us multi-core processors
these days. And my point is that multi-threading is in the process of
becoming equivalent to concurrent programming and C++ needs to address
that issue.
I have a threading library in C++ that is portable to Windows & Linux,
and probably another other OS's where the kernel-mode people did their
part and provided the minimum set of synchronization primitives. It is
not a full-featured library. There are some questions that I did not
try to answer. There are also some areas that could be cleaner. But
the key point is that the interface is mostly clean, the interface is
portable, the model does not leave you wrestling with your own brain as
you use it, something I would imagine other people who have tried to
make "thread objects" have discovered (I learned the hard way that it
is not good to regard a thread as an object).
The point is that C++ and threading are alive and well. People use
them together. Some people use the native API of their OS, which is
not always pleasant to use. Some people wrap these API's.
The point is that you don't know that it works, and that it
works only by chance (and may actually fail once you start using
a multi-core processor). The point is that you don't have any
guarantees with regards to what the language or the compiler
provides.
Maybe your happen with a definition of "working" as "it hasn't
crashed yet", but my customers generally aren't.
But I do not think it is fair to say that we do not understand the
importance of multi-threading programming by C++ programmers. We do.
What we are saying is that the fundamentals of multi-threading, barring
some massive break through in the state-of-the -art, are
well-understood,
Which explains why so many programmers get it wrong. (The
people who implemented std::basic_string in g++ are not idiots;
they're some of the more gifted programmers I know. Never the
less, there is a threading error in the code.)
and it is our opinion that those who think that the language
itself is somehow deficient in this regard are mistaken.
You can think what you like, but you can't argue with hard
facts. It is impossible, today, to write a multi-threaded
program with defined behavior.
Anything that the C++ community does with regard to "adding threading
to the language" is going to eventually lead right to the primitives
that actually implement synchronization, primitives that are 40 years
old.
For the moment, I think the committee has only begun to scratch
the surface with regards to primitives. Before defining the
primitives, it is necessary to define a basic memory model; what
it means to read or wite to memory.
After all, when we talk about "threading", we are talking about
synchronization.
Hardly. There's a lot more to it than that.
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]