[dmd-concurrency] shared arrays

Sean Kelly sean at invisibleduck.org
Thu Jan 14 07:16:45 PST 2010


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.


More information about the dmd-concurrency mailing list