共享内存体系结构下,为解决锁同步导致的并发性能瓶颈,本文提出了一种基于硬件CAS (比较交换)原语的无锁同步算法。该算法利用底层处理器提供的比较交换指令,实现了在多核多线程环境下对共享变量的非阻塞同步操作,通过采用全局标记值的方式,避免了传统设计中由于使用内存字标记导致的性能开销,同时确保数据在并发访问中的一致性。实验结果表明,本文算法可以高效地支持任意多字的CAS同步,提高了对共享数据的并发访问性能,具有较好的可扩展性。
Lock-based synchronization may become a performance bottleneck which limits the concurrency in shared -mem-ory machines .In order to solve this problem ,a lock-free synchronization algorithm based on hardware CAS (Compare And Swap ) primitive is proposed in this paper .In the proposed method ,compare and swap instruction provided by underlying processor is used to implement non-blocking synchronization for shared variables in multi-core or multi-thread environment .Global mark value is in-troduced to avoid performance overhead caused by bits reservation of memory word in the traditional design ,and guarantee the con-sistency .Theoretical analysis and experimental results show that the proposed method can efficiently support arbitary multi-word CAS synchronization ,improve the concurrent access performance and provide good scalability .