C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

C++ Threads, what's the status quo?
Goto page 1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Dec 27, 2006 2:32 am    Post subject: C++ Threads, what's the status quo? Reply with quote



While people as brilliant as Hans have already come up with the whole
bunch of proposals and ideas which make me feel that threads in C++
will have a bright future, I did come across an article that seemingly
said that there was something wrong with the way people did the whole
thing.
While I'm certainly not qualified to judge the thing, I'd like to put
the post to the forefront, and let people who can to comment on this.

http://enfranchisedmind.com/blog/archive/2006/10/21/163

To quote a few lines(please redirect to the blog to see the details,
coz I haven't asked the one if I could put the entire post(which is
pretty long) here):

I'm reading this post on the C++ committee's dealings on threading,
and, I am pleased to announce, there is absolutely no chance what so
ever of anything sane, workable, or sensible accidentally arising from
these precedings...


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Gianni Mariani
Guest





PostPosted: Wed Dec 27, 2006 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote



pongba (AT) gmail (DOT) com wrote:
....
Quote:
http://enfranchisedmind.com/blog/archive/2006/10/21/163
....


It appears the major gripe is the simplification to use fully
synchronized atomic access and the effect on performance.

While for some code this may be a major factor, in most cases it is not.

Threading is a complex beast to most people, and so is C++. If the
default model was to make things so complex that most people who are
already familiar with threaded code become alienated by complexity, then
we're not looking at a winning formula.

The few users with performance critical applications that need the
control of load/store visibility can continue to experiment and there is
nothing stopping them from using these "optimal" primitives in their
applications - like they are today.

Personally, I think it's a sound compromise.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Francis Glassborow
Guest





PostPosted: Wed Dec 27, 2006 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote



In article <1167139437.608835.58780 (AT) 79g2000cws (DOT) googlegroups.com>,
pongba (AT) gmail (DOT) com writes
Quote:
While people as brilliant as Hans have already come up with the whole
bunch of proposals and ideas which make me feel that threads in C++
will have a bright future, I did come across an article that seemingly
said that there was something wrong with the way people did the whole
thing.
While I'm certainly not qualified to judge the thing, I'd like to put
the post to the forefront, and let people who can to comment on this.

http://enfranchisedmind.com/blog/archive/2006/10/21/163

To quote a few lines(please redirect to the blog to see the details,
coz I haven't asked the one if I could put the entire post(which is
pretty long) here):

I'm reading this post on the C++ committee's dealings on threading,
and, I am pleased to announce, there is absolutely no chance what so
ever of anything sane, workable, or sensible accidentally arising from
these precedings...

I am greatly saddened by the tone of that article. He chooses to quote
private discussions (and I am certain that he did so without the consent
of the person quoted and without the context)

The comments are arrogant and if he was just an observer the blogger is
unlikely to know as much as those who have been working on this solidly
for over a year.

--
Francis Glassborow ACCU
Author of 'You Can Do It!' and "You Can Program in C++"
see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Mathias Gaunard
Guest





PostPosted: Wed Dec 27, 2006 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

pongba (AT) gmail (DOT) com wrote:
Quote:
While people as brilliant as Hans have already come up with the whole
bunch of proposals and ideas which make me feel that threads in C++
will have a bright future, I did come across an article that seemingly
said that there was something wrong with the way people did the whole
thing.
While I'm certainly not qualified to judge the thing, I'd like to put
the post to the forefront, and let people who can to comment on this.

http://enfranchisedmind.com/blog/archive/2006/10/21/163

He's basically only saying he doesn't like atomics because they disable
optimizations.
Given that it is simply their *goal*, this remark is just stupid.

He's also saying that a high-level language proposal was refused and the
same proposal as a library was considered.
It's simply because it was decided not to add needless elements to the
language. Only low-level ones are added.


Quote:
I'm reading this post on the C++ committee's dealings on threading,
and, I am pleased to announce, there is absolutely no chance what so
ever of anything sane, workable, or sensible accidentally arising from
these precedings...

That guy clearly says he doesn't like C++. He probably doesn't even
realize how C++ code should be.
For example, he says he doesn't understand why so much attention was
given to the design rather than the behaviour.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Howard Hinnant
Guest





PostPosted: Wed Dec 27, 2006 11:31 pm    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

In article <1167139437.608835.58780 (AT) 79g2000cws (DOT) googlegroups.com>,
pongba (AT) gmail (DOT) com wrote:

Quote:
While people as brilliant as Hans have already come up with the whole
bunch of proposals and ideas which make me feel that threads in C++
will have a bright future, I did come across an article that seemingly
said that there was something wrong with the way people did the whole
thing.
While I'm certainly not qualified to judge the thing, I'd like to put
the post to the forefront, and let people who can to comment on this.

http://enfranchisedmind.com/blog/archive/2006/10/21/163

To quote a few lines(please redirect to the blog to see the details,
coz I haven't asked the one if I could put the entire post(which is
pretty long) here):

I'm reading this post on the C++ committee's dealings on threading,
and, I am pleased to announce, there is absolutely no chance what so
ever of anything sane, workable, or sensible accidentally arising from
these precedings...

It is so much easier to stand up, shout, point and ridicule, than it is
to actually help. People have been doing that since there were people.

Thank goodness there are some people who have the courage to put their
hide on the line and make concrete proposals for a better standard. You
can too. On the library side you can send proposals directly to me.

But check the attitude at the door. You may find out that you're not
the only smart person working towards a better C++ standard.

Howard Hinnant
Library Working Group Chair

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Howard Hinnant
Guest





PostPosted: Sat Dec 30, 2006 6:32 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

In article <1167379436.110055.298760 (AT) 79g2000cws (DOT) googlegroups.com>,
"Bertrand Motuelle" <tib.motuelle (AT) laposte (DOT) net> wrote:

Quote:
Beman Dawes wrote:
Francis Glassborow wrote:
I am greatly saddened by the tone of that article. He chooses to quote
private discussions (and I am certain that he did so without the consent
of the person quoted and without the context)

Not to mention that it is almost certainly a mis-quote. I've said
several times that the committee would be bad shape without Hans'
encyclopedic knowledge of *garbage collection*. As for threading, the
committee has a number of people with both broad and deep knowledge and
experience.

--Beman

To be fair with the blogger, the corresponding quotes can be found in a
public article of the C++ source:
http://www.artima.com/cppsource/threads_meeting.html

Yes, it would have been most helpful if the blogger had referenced where
he was getting his quotes from. I was familiar with the article and
thus easily able to locate it as well. But others might not be, or
might not go to the trouble to hunt the reference down.

-Howard

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Guest






PostPosted: Wed Jan 03, 2007 1:07 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Quote:
To be fair with the blogger, the corresponding quotes can be found in a
public article of the C++ source:
http://www.artima.com/cppsource/threads_meeting.html

I found a interesting follow up post called "The Solution to C++
Threading is Erlang":

http://radio.weblogs.com/0103955/categories/stupidHumanProgramming/2006/12/2
5.html

and a similar blog post about the erlang way..

http://codemines.blogspot.com/2006/09/hell-is-multi-threaded-c-program.html

They argue that multi threading is complicated and error prone, and
that the alternative of using shared memory stores between native OS
processes are to slow. But they say there is an alternative model. A
mix between the two. You could have threads that dont share any data
but only communicate thru messages. That kind of thread might sound
alot like a regular native OS process but i guess the difference is
that you have more control over them and they are more efficient
because they are supported directly by the language instead of by the
operating system.

Sounds simple and good to me. What do you guys think?

I guess the down side would be that to share any data you would be
sending a copy of it. The cost of getting simple value semantics might
just be worth it..

Regards Patrik


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Thant Tessman
Guest





PostPosted: Thu Jan 04, 2007 1:28 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Howard Hinnant wrote:

[...]

Quote:
It is so much easier to stand up, shout, point and ridicule, than it
is to actually help. [...] Thank goodness there are some people who
have the courage to put their hide on the line and make concrete
proposals for a better standard. [...]

Threading is basically a solved problem and has been for a while.
Someone mentioned Erlang. I'll mention Concurrent ML. I'll also mention
first-class continuations which are supported by several languages and
with which you can construct your own threading mechanism that looks
like anything you want. Shoehorning threading into C++ just seems like a
misallocation of talent and effort--counterproductive even. Is it
"ridicule" to point this out?

-thant

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Mathias Gaunard
Guest





PostPosted: Fri Jan 05, 2007 3:34 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

patrik.kahari (AT) googlemail (DOT) com wrote:

Quote:
You could have threads that dont share any data
but only communicate thru messages.

I guess the down side would be that to share any data you would be
sending a copy of it.

Unfortunetely, SMP architectures are more popular.
So sharing is more efficient.



--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
James Kanze
Guest





PostPosted: Sun Jan 07, 2007 4:42 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Le Chaud Lapin wrote:
Quote:
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.

Quote:
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.)

Quote:
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.

Quote:
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.

Quote:
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 (AT) gmail (DOT) 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! ]
Back to top
Simon Farnsworth
Guest





PostPosted: Mon Jan 08, 2007 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Le Chaud Lapin wrote:

Quote:
James Kanze wrote:
Le Chaud Lapin wrote:
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.

I never asked the compiler for any guarantees. What did you study in
university? I do not mean to attack you personally, but frankly, these
concepts are as old as multi-threading itself. I am appalled that so
many people seem not to understand multi-threading.

There are *important* threading related guarantees that the standard has

nothing to say about. For example, there's no way to ensure that cached
memory is consistent between two CPUs running two threads; you have no way
to tell if a particular operation represents a synchronisation operation.

Further, the standard is silent on whether you can assume strict
consistency, weak consistency, sequential consistency, causual consistency,
or another consistency model.

These are both important if you want to guarantee that an operation between
two threads working in parallel on the same block of memory does what you
expect. In a weak consistency model, it's impossible to implement a working
mutex without knowing which operations are synchronisation operations; your
environment typically handles this by arbitrarily declaring that some
library calls are synchronisation operations.

On top of this, in a weak consistency model, you need to know which
operations are synchronisation operations to be certain that two processors
have the same view of memory; without that knowledge, two different
processors reading from the same bit of memory are entitled to return
different values.
--
Simon Farnsworth

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Chris Thomason
Guest





PostPosted: Mon Jan 08, 2007 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

ACK! I forgot the darn link:

http://groups.google.com/group/comp.lang.c++.moderated/msg/e161a53de7c2290e

Sorry for any confusion!


;^(...

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Le Chaud Lapin
Guest





PostPosted: Mon Jan 08, 2007 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Mirek Fidler wrote:
Quote:
Ahh... I guess you should seriously reconsider the issue.

Recommended reading is e.g. google: "why double checked guard does not
work".

Just for starters, if you have

Shared y;
Mutex y_lock;

void fn() {
y_lock.Lock();
y = 10;
y_lock.Unlock();
}

nothing in C++ standard prevents C++ compiler to generate machine code
equivalent to

void fn() {
y = 10;
y_lock.Lock();
y_lock.Unlock();
}


Are you saying that the C++ standard does not prescribe sequential
execution of statements in a single-threaded program?

If that is the case, then I could write a single-threaded application
that would not behave as a programmer would expect using an example
very similar to the one you gave.

Also, do you have a link regarding the quote above for Google? I
looked, and did not find what I think you were suggesting.

-Le Chaud Lapin-


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Le Chaud Lapin
Guest





PostPosted: Mon Jan 08, 2007 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Chris Thomason wrote:
Quote:
ACK! I forgot the darn link:

http://groups.google.com/group/comp.lang.c++.moderated/msg/e161a53de7c2290e

Sorry for any confusion!


;^(...

Hi Chris. I took a look at this link. I also wrote a post recently
essentially saying that DCL does not work, so a bit of clarification:

DCL will work easily if one goes to hardware. It appears from this
link that assembly language instructions are being used. That
Microsoft appears to have provided "support" for atomic operations at a
higher-level is obviously not portable.

There is a large group of people that is hell-bent on finding some way
to do DCL and other tricks purely in C++ and expecting it to be
portable, and it is impossible, as I keep stating.

But, if you allow for the possibility of a few assembly language atomic
operations, you have the entire world of synchronization at your
disposal, and that will work very well.

We must qualify the statement DCL works - it works when one is allowed
to exit the realm of portability. Otherwise it does not work (in
general).

-Le Chaud Lapin-


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Le Chaud Lapin
Guest





PostPosted: Mon Jan 08, 2007 10:10 am    Post subject: Re: C++ Threads, what's the status quo? Reply with quote

Simon Farnsworth wrote:
Quote:
Further, the standard is silent on whether you can assume strict
consistency, weak consistency, sequential consistency, causual consistency,
or another consistency model.

These are both important if you want to guarantee that an operation between
two threads working in parallel on the same block of memory does what you
expect. In a weak consistency model, it's impossible to implement a working
mutex without knowing which operations are synchronisation operations; your
environment typically handles this by arbitrarily declaring that some
library calls are synchronisation operations.

I am happy to admit, I have no idea what these terms mean, but I will
look them up in about 10 minutes.

However, I see something missing in your post: atomic operations. This
is the essence of my thesis. I keep saying there will not be any
guarantees in any language if you do not have:

1. Harwdware-based atomic operations.
2. OS Support of synchronization.

People keep responding by demonstrating or alluding to C++ code that is
bound to not behave the way the programmer expected it to.

If that is the case, then I have said that a 1000 times:

No programmer in the world who is going to "implement safe threading in
C++" by writing generic C++ code without regard for 1 & 2 above.
*That* is where the guarantees come from.

-Le Chaud Lapin-


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Goto page 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.