
on Sat Aug 06 2011, Gottlob Frege <gottlobfrege-AT-gmail.com> wrote:
In lockfree programming you need to look at what is in your data structure, what are the possible states. At any 'atomic sequence point' or 'publication point' which known good state are you in. This is somewhat the same as any program - "what states can you be in, they better all be correct". Lockfree just tends to have more states in a small amount of code, and less (ie 0) "internal blocks" where you can temporarily break the invariants. Your code needs to be somewhat convoluted so that: 1. temporary internal spots exist where invariants can be broken 2. publication/restoration of the invariant state is a single atomic operation
This is really not all that different from single-threaded programming. If I do: void X::f() { this->a = 1; // break invariant y->g(); this->a = 0; // restore invariant } I had better be sure that y->g() can't observe my broken invariant. The problems are not all that different. -- Dave Abrahams BoostPro Computing http://www.boostpro.com