Re: C++ Threads, what's the status quo?
Zeljko Vrba wrote:
On 2007-01-16, Le Chaud Lapin <jaibuduvin@gmail.com> wrote:
I do not know what you mean by "support for concurrent execution." As
far as I am concerned, C++ already does a respectable job of supporting
concurrent execution, in whatever context there exists the possibility
of having concurrent execution.
If this is so, please consider the following case.
Assume that we have functions enable_irq() and disable_irq() that enable/
disable interrupts on the (local) CPU. Assume further that you have a
CPU-private variable 'int x;' and observe the following piece of code:
disable_irq();
++x;
enable_irq();
How do you ensure, within the current C++ language (and without resorting to
various compiler extensions), that the compiler does not move '++x;' across
either function?
I showed in response to same problem put forth in a different post that
this is a problem more related to optimization than multi-threading.
IOW, the problem would be present whether the application were
multi-threaded or single-threaded. Yes, it affects multi-threading,
but there are many "anomalies" in C++ that affect many things. An
orthogonal approach to ameliorating the language might be better.
There are strata of problem domains that must be understood to
facilitate multi-threaded programming in C++. I do not think this
particular one should be grouped with the others.
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]