[dmd-concurrency] shared arrays
Kevin Bealer
kevinbealer at gmail.com
Wed Jan 27 20:03:18 PST 2010
On Wed, Jan 27, 2010 at 7:19 PM, Michel Fortin <michel.fortin at michelf.com>wrote:
> Le 2010-01-27 à 18:25, Andrei Alexandrescu a écrit :
>
> > Consider a shared array:
> >
> > shared int[] x;
> >
> > What can be done with it? It's tricky; the array has two words worth of
> info and we can't assume 128 bits can be atomically written on a 64-bit
> machine.
>
> Isn't that a great case for a lock pool controlled with a hash table? If
> you have dismissed that option, why?
>
>
I think the larger question is, what are the common use cases for shared?
It seems dangerous to rely on per-field atomicity too much for ordinary
tasks; clearly (int32)++ is supportable without heroic measures and
(int[][]) ~= (int[]) probably is not, or is at least harder / trickier. If
you don't understand modern CPU architecture it's not self-evident what the
rules are, which makes this topic pretty much restricted to people with
advanced skills as these things are reckoned nowadays. Is shared just to
support building synchronization tools and special purpose things like
rapid-access stacks, or is it a tool every developer is expected to use
commonly?
It may be that our profile of who is supposed to be using it for what will
answer a lot of questions about what we need to support, how fast it has to
be, and what trade-offs are appropriate. Or at least, I will be less
confused (or more likely, confused for a different reason).
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-concurrency/attachments/20100127/60bcd6ea/attachment.htm>
More information about the dmd-concurrency
mailing list