That's what a standard is for. The POSIX threads standard is pretty clear
on it's purpose: to implement a standard API to handle threads. If some
people keep ignoring a standard for over 15 years then what good will it
do if yet another standard is defined to deal with this very same issue?
That's why we have for over a decade a standard for an API designed to
handle threads.
I don't believe this to be any relevant. There is a standard that defines
an API to handle threads. I don't see any reason why the people dedicated
in developing a programming language would be forced to ignore an API when
they try to add support for a particular feature.
What's wrong with pthreads? And what do you mean by "more formalized"?
That's irrelevant. It has nothing to do with any API and everything to do
with the people in your anectodal example. A standard doesn't force any
knowledge on anyone remotely related to a subject, which means that
adopting a current standard or inventing a new one will have absolutely no
impact on this issue.
That's irrelevant. The pthreads standard defines an API. The
implementaton details are left to the programming language and underlying
platforms. If there is a need to define any behavior of a given
programming language then this issue should be dealt by the people who
dedicate their time to manage that programming language. Yet, defining
behavior which has been previously left undefined does not force anyone to
design a new standard API from scratch while ignoring an established
standard designed for this very purpose.
As opposed to a piecemeal reply, let me make it short.
First, pthreads threads is a highly informal standard compared to the
proposed C++ semantics. There are several dark corners in pthreads
where the behavior is less than clear. It's badly specified. The new
proposed C++0x standard goes a lot better in clarifying corner cases
of what does and does not work. Please see:
http://www.hpl.hp.com/techreports/2008/HPL-2008-56.pdf
for a comprehensive review of the new threading standard. There's a
couple of places in the doc which describe the ambiguity of the
current pthreads standard, and at least one point where nearly all
POSIX pthreads implementations are glaringly not conforming to the
pthreads standard (see: "3. Making Trylock Efficient" in the above
link).
Second, it's not complete. It doesn't specify Linux kernel calls read,
write, and data dependent barriers, what C++0x calls
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
It also lacks a way to say "No, I really know what I'm doing, and this
race condition is harmless" which C++0x calls
memory_order_relaxed,
And to make everyone's life easier, you can specify that the memory
operation participates in the global ordering, aka that it's
"sequentially consistent"
memory_order_seq_cst
Posix pthreads doesn't support any of that except memory_order_acq_rel
(or is it memory_order_seq_cst?), which sometimes results in people
going to the assembly for what the Linux kernel calls read, write, and
data dependency barriers. This leads to fun conversations between
experts on what exactly is going on, such as:
http://groups.google.com/group/comp...read/thread/fcef57c539a42ef5/be98b8ef87ff64a4
Does the volatile do anything? Obviously not portably, but will it
make your compiler + implementation on your hardware produce the
correct results? Do you need gcc's "memory" clobber or not for that
inline assembly? Frankly, this kind of stuff isn't documented
anywhere. You could spend days talking to the actual compiler writers
and consult your chipsets assembly docs, but even after that you
probably won't know for sure. I for one think this is an entirely
unsatisfactory state of affairs.
I suppose you could spruce up pthreads to do this, but it seems that
they have not. I /think/ that the C and C++ committees have been in
contact with the POSIX pthreads people. How do the pthreads people
feel about this standardization? Why haven't they updated POSIX
pthreads to fix the known issues and more formalize their model, and
add read, write, data dependent barriers? I wonder if the POSIX people
thought it would be better to put this stuff in the C and C++
standards.
Third, I want portable threading that everyone supports. It's
unfortunate that a certain OS decides to not support it out of the
box. However, does it make sense to talk about pthreads conformance
without the broader scope of POSIX conformance? Windows will never be
POSIX conformant, but it might supply a conforming pthreads interface.
Is the POSIX pthreads standard set up to allow Windows to claim
"pthreads" compliance without any other part of POSIX?
Fourth, as a minor point, I still think that it makes sense to put
something so critical and inherent to compiler code generation into
the language standard and not leave it to a separate standard. It
would be ridiculous if malloc and friends were in a different standard
than the C standard, or if typedef was in a different standard than
the C standard. The same is true of threading. It's so integral to the
language from a user point of view and implementer point of view that
it ought to be in the same standard. (I would argue that the same is
true of "shared objects" aka "shared libraries" aka "DLLs".)