59b Subj : Re: A question about atomic_ptr To : comp.programming.threads From : Joe Seigh Date : Sat Apr 16 2005 08:31 am On Fri, 15 Apr 2005 22:03:14 -0700, Chris Thomasson <_no_damn_spam_cristom@_no_damn_comcast.net_spam> wrote: >>> Ok, Joe said that "It needs the virtual storage to always be valid so >>> the load locked won't segfault." >>> >>> Not sexy. >>> > > [...] > >> BTW, it's the same restriction lock-free LIFO stack using DWCAS w/ version >> counts has. > > So, atomic_ptr for PPC-64 needs to have some sort of static/tracked storage > wrt atomic_ptr_ref's? You can get around all of that by allocating static or > "collected" arrays of atomic_ptr_ref's. Then you would use the index to > atomic_ptr_ref as the "pointer" to it. PPC-64 has ldarx/stdcx. It just needs the storage to always be valid for loading from event if its no longer a valid object. Same as the lock-free LIFO stack needs when it does a load of the next pointer field in what it thinks is the item on the top of the stack. Not until it does the dwcas on the stack head/version number does it validate that the value it fetched was good. This is different than the lock-free FIFO queue which needs to pool the nodes since the storage value fetched does matter. DWCAS based refcounting doesn't have this problem since the refcount is incremented atomically with the fetch of the pointer. -- Joe Seigh . 0