[cpp-threads] Fixing the thread type

Boehm, Hans hans.boehm at hp.com
Mon Nov 21 22:33:01 GMT 2005


I'm concerned about having more than one concurrent standardization
effort in this area.

Clearly the C++ committee is interested in some sort of threads API
standard.  My impression was that they were leaning to a low-level
pthreads-like, C-compatible, interface plus something at a higher level,
which might be modified Boost threads.[1]

This might not exactly be a Posix C++ binding, but it definitely seems
to be closely related.  It might in fact dodge issues like thread
cancellation.  But it still seems strange to have two efforts which are
so closely related going on in two different committees.

I would personally prefer to concentrate on the C++ effort, at least for
now, for two reasons:

1. In order to get any of this really right, it needs to interact
correctly with, and share terminology with, the memory visibility rules,
which clearly belong into the C++ standard.

2. Although I'm worried about getting agreement on a threads API,
including it in the language spec does make it possible to write
portable multithreaded applications, where "portable" includes non-Posix
platforms.  I think this would be a very good thing.

It may well be that when the dust settles, there is still room for a
full Posix C++ binding.  But doing these in parallel strikes me as
confusing matters further.

Hans

[1] I did finally get a chance to look at the RedHat Pthreads-on-windows
implementation, as I had promised to during the C++ meeting.  Based on a
quick reading, I didn't get the impression that this adds a huge amount
of overhead, though it clearly adds some.  Thus it does seem reasonable
to me to require the basic Pthreads primitives as part of any C++
threads standard.  In particular, the cost of uncontended locking
doesn't seem to be affected much.  Condition variable primitives are
more expensive, but I would guess that that cost is still no more than
on the same order as the context switch.  I expect that both Doug and
Alexander can comment more authoritatively.  Herb may also want to
comment.

> -----Original Message-----
> From: cpp-threads-bounces at decadentplace.org.uk 
> [mailto:cpp-threads-bounces at decadentplace.org.uk] On Behalf 
> Of Jason Merrill
> Sent: Monday, November 21, 2005 12:35 PM
> To: C++ threads standardisation
> Subject: Re: [cpp-threads] Fixing the thread type
> 
> 
> Nick Maclaren wrote:
> > Alexander Terekhov <alexander.terekhov at gmail.com> wrote:
> > 
> >>We had a discussion about whether there should be a project 
> to develop 
> >>a C++ binding to POSIX. We think that we should investigate whether 
> >>IEEE would be interested in doing this.
> > 
> > It's a crazy idea.  Until and unless POSIX comes up with a viable 
> > threading model, that is binding to a mirage.
> 
> Viable or not, it exists, people use it with C++ code, and it 
> ought to 
> be standardized.
> 
> My personal interest in a C++ binding has to do with the 
> interaction of 
> pthread_cancel and EH, which is currently badly broken on 
> Linux because 
> of a deadlock between the libc and C++ people.  I have a dream that a 
> POSIX C++ binding could break that deadlock.
> 
> Jason
> 
> -- 
> cpp-threads mailing list
> cpp-threads at decadentplace.org.uk 
> http://www.decadentplace.org.uk/cgi-bin/mailman/listinfo/cpp-threads
> 



More information about the cpp-threads mailing list