[M3devel] FreeSlots/lookup slot locking

Jay K jay.krell at cornell.edu
Wed Nov 11 07:11:10 CET 2009


Tony:

> Also, I am unconvinced that the current implementation of AssignSlot can ever
> be correct without the critical section. It requires atomic update of both
> the slots array pointer (with the new slots) *and* the array elements. This
> requires a proper CS instead of non-blocking synchronization.


 

I don't see it.

I could be wrong.

 

The writes are done within a critical section, to avoid racing with other writers.

 

Writes interact with readers in that:

 

            SUBARRAY (new_slots^, 0, n) := slots^;
finish writing to the array elements

MemoryBarrier

            slots := new_slots;


 

so readers don't see slots unless it has been fully initialized.

 

AssignSlots should also be able to be lock free via InterlockedCompareExchangePointer.

 

 

 - Jay

 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091111/509e3a6f/attachment-0001.html>


More information about the M3devel mailing list