Never mind that cmpxchg() is a spinlock in different clothes.
Yes and no. It's reuse of existing "spinlock". Each and every access to every byte of RAM on SMP system is covered by "spinlock" anyway - think about cache cogerency! Yes, it's not really implemented as spinlock and there are different implementations of idea but the end result is the same: access to every byte in modern SMP systems is covered by "sort of spinlock" (and if two processors stomp each other feets too often system slows down to a crawl as you can guess). And cmpxchg() is using this feature - that's all. Since each and every access to any variable should be held with such "spinlock" held it's not slower then simple access without cmpxchg() function.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds