Re: Threading issue in next standard
kanze wrote:
wkaras@yahoo.com wrote:
.... typically, what is needed in a multithreaded
context is an explicitly induced point in the program where all
previous writes (regardless of the target type) become visible
(before any of the following writes become visible).
.... What you usually need in multithreading is a
sequencing guarantee---that (all) preceding writes will become
visible to all observers before any of the following writes.
(Note that this generally implies some sequencing actions on the
part of the observers as well.)
Does it need to be "all writes"?
Perhaps I've been corrupted by my years doing
supercomputing, but when I think of parallel processing
(and I think of multithreading as parallel processing), I
envision the model system as one with a bunch of
CPUs (possibly with local memory)
with a vast network between the CPUs and the (shared)
memory. When a CPU updates a (shared) variable,
the update slowly "percolates" out through the network.
In this situation, waiting for "all writes" from all CPUs
to be done would require all CPUs to stop and wait
for the memory network to become quiescent.
Since this would happen every time any CPU requests
a "wait for all writes", it would cause an O(no of processors)
performance hit.
I don't know about anyone else, but when I use
mutexes, I always associate each mutex with a set
of (shared) variables that it controls, so what I would
want is to be assured that all writes to the variables
controlled by this mutex were visible to my
thread before the mutex was considered locked.
In other words, for me, synchronization always
applies to an object or set of objects, not to the
universe of objects.
If I may invent some ill-advised syntax, I'd want something
like
synchronizable group_a { int a; std::string b; MyClass c; };
lock_group( group_a );
a += 1;
unlock_group( group_a );
-- Alan McKenney
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]