Subj : Re: atomic operations api added to AppCore... To : comp.programming.threads From : Ronald Landheer-Cieslak Date : Fri Feb 25 2005 08:30 am awaken wrote: > So is it correct code for StabilizeRight ? > > void StabilizeRight(const AnchorType lrs) > { > HPRecType *hp0 = lrs.left; // haz ptr > HPRecType *hp1 = lrs.right; Hazard pointers are normally thread-local (using tls). I don't see your implementation doing that (they live on the stack in your case, which means your SMR implementation has no way of getting at them) > if( m_anchor.anchor != lrs.anchor) // 64bit compare > return; > NodeType *pprev = lrs.right->left; > NodeType *hp2 = pprev; > if( m_anchor.anchor != lrs.anchor ) return; Where is m_anchor from? Is this a class method? (I'll assume it's a global deque anchor...) > NodeType *prevnext = pprev->right; > if(prevnext != lrs.right) > { > if( m_anchor.anchor != lrs.anchor ) return; > if(! CAS(&pprev->right, prevnext, lrs.right) ) return; > } > CAS64( &m_anchor.anchor, lrs, AnchorType(lrs.left, lrs.right, > eStable); I don't think this would compile if AnchorType doesn't have a constructor.. > } > > > > > // I use 64bit CAS on IA-32, so Anchor type // defined to hold 2 32-bit > pointers > // struct AnchorType > { > union > { > unsigned __int64 anchor; // 64bit type in MSVC++ > unsigned int StatusType:2; > struct > { > PackedPtr< NodeType > left; // 32 bit, 2 shared w/Status > PackedPtr< NodeType > right; // 32 bit > }; > } ; Are you sure you don't need those two bits of your pointer? Are you sure you never forget to mask your pointer so you take the two bits out and don't use corrupted pointers - ever? Other than that, it looks OK to me. rlc .