[dmd-concurrency] shared arrays

Steve Schveighoffer schveiguy at yahoo.com
Fri Jan 15 09:43:04 PST 2010


You can't use anything in the array struct itself to lock the array data because the struct data is not necessarily shared.

-Steve



----- Original Message ----
> From: Sean Kelly <sean at invisibleduck.org>
> To: Discuss the concurrency model(s) for D <dmd-concurrency at puremagic.com>
> Sent: Fri, January 15, 2010 12:26:56 PM
> Subject: Re: [dmd-concurrency] shared arrays
> 
> Okay, no big deal.  So we set either ptr or len to size_t.max.  Either should be 
> safe as a sentinel.
> 
> On Jan 15, 2010, at 5:37 AM, Sean Kelly wrote:
> 
> > Darnit, you're right.  I dunno what I was thinking.
> > 
> > On Jan 14, 2010, at 1:21 PM, Kevin Bealer wrote:
> > 
> >> I'd suggest setting the high bit of the length instead.  If I have this 
> scenario:
> >> 
> >> char[] foo = "abcd".dup;
> >> char[] bar = foo[1..2];
> >> Then bar is an array with an odd address.
> >> 
> >> Kevin
> >> On Thu, Jan 14, 2010 at 10:16 AM, Sean Kelly wrote:
> >> On Jan 14, 2010, at 4:10 AM, Steve Schveighoffer wrote:
> >> 
> >>> Having implemented the array append patch to fix stomping, and reading the 
> dmd-concurrency debate, I realized that what I implemented is no good for shared 
> arrays.
> >>> 
> >>> In fact, I wonder how shared arrays can support any array operations
> >> 
> >> I sent an email about this a while back.  In short, if we're going to allow 
> array ops on shared arrays at all I think they'll have to use atomic ops to 
> "lock" the array for the length of the update.  Basically, set the 1 bit of the 
> ptr field to indicate the array is locked.  This gets tricky when more than one 
> shared array is involved because the lock has to be acquired on each, and 
> because different ops may try to lock arrays in different orders, if a spinlock 
> acquire times out the code will have to release all the locks it's acquired, 
> wait some random interval, and try again.  Pretty complicated stuff if the goal 
> is just to support shared array ops.
> >> _______________________________________________
> >> dmd-concurrency mailing list
> >> dmd-concurrency at puremagic.com
> >> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
> >> 
> >> _______________________________________________
> >> dmd-concurrency mailing list
> >> dmd-concurrency at puremagic.com
> >> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
> > 
> > _______________________________________________
> > dmd-concurrency mailing list
> > dmd-concurrency at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
> 
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency



      


More information about the dmd-concurrency mailing list