Jason Merrill wrote:
On Thu, 14 Apr 2005 10:12:37 -0400, "Michael N. Moran" <[EMAIL PROTECTED]>
wrote:
Jason Merrill wrote:
The C++ committee (well, a subgroup represented at this meeting by Hans
Boehm) is working on a memory model that supports threaded programs.
As someone who uses the C++ language and multi-threading
extensively in embedded systems, I have come to the following
belief/opinion.
The language (C++) *should not* have dependencies
upon threading. IMHO, threading is a layer above a
systems programming language, and having dependencies
upon upper layers is evil.
But the memory model for the language must provide semantics that make it
possible for threaded programs to be written. Currently, if you want to
write a portable pthreads program you need to use a mutex around all uses
of shared memory, because they are the only way to guarantee sequential
memory ordering. The volatile proposal provides a lighter-weight way to
write portable code with explicit memory ordering. You need this for
lockless algorithms to work.
I am not arguing against such a language capability,
I am only arguing against overloading volatile to achieve
the goal. Thus, the other suggestions.
It seems to me that the current specification of volatile already requires
an lwsync around volatile reads and writes, to guarantee that all previous
stores have been completed and later ones have not started.
I can see how you could arrive at this point-of-view
if you accept the view that the C++ language is responsible
for understanding multi-threading. However, in the absence
of that responsibility, there is no reason for the compiler
to perform this function.
I prefer requiring the programmer to be explicit,
and understand the environment for which he writes.
In the spirit of C++, I do not want to pay overhead
for features that I do not need or use. And, as an
embedded systems programmer, I need and use volatile
frequently.
--
Michael N. Moran (h) 770 516 7918
5009 Old Field Ct. (c) 678 521 5460
Kennesaw, GA, USA 30144 http://mnmoran.org
"So often times it happens, that we live our lives in chains
and we never even know we have the key."
The Eagles, "Already Gone"
The Beatles were wrong: 1 & 1 & 1 is 1