Subj : Re: Adding thread support for C... To : comp.programming.threads From : Chris Friesen Date : Tue Aug 02 2005 11:29 pm David Schwartz wrote: > "Chris Friesen" wrote >>Really? How would you make the lock/modify/unlock cycle faster than a >>single atomic increment? > Who says the CPU *has* an atomic increment? It may only have an atomic > compare-and-swap. Okay, point. >>In the optimal uncontended case each of the lock/unlock will be an atomic >>operation, so you end up with one extra atomic as well as whatever >>modification that you were trying to do. > Perhaps the CPU has heavily optimized atomic 'lock' and 'unlock' > operations and its atomic increment is implemented as some kind of > read/increment/compare-exchange/loop-on-fail thing. Again, I admit it could be done this way. Out of curiosity, do you know of any such architectures? Chris .