Subj : Re: Adding thread support for C... To : comp.programming.threads From : David Schwartz Date : Tue Aug 02 2005 08:29 pm "Chris Friesen" wrote in message news:11evu9mn4eo0q5d@corp.supernews.com... > 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. > 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. DS .