We present "Reciprocating Locks", a novel mutual exclusion locking algorithm, targeting cache-coherent shared memory (CC), that enjoys a number of desirable properties. The doorway arrival phase and the release operation both run in constant-time. Waiting threads use local spinning and only a single waiting element is required per thread, regardless of the number of locks a thread might hold at a given time. While our lock does not provide strict FIFO admission, it bounds bypass and has strong anti-starvation properties. The lock is compact, space efficient, and has been intentionally designed to be readily usable in real-world general purpose computing environments such as the linux kernel, pthreads, or C++. We show the lock exhibits high throughput under contention and low latency in the uncontended case. The performance of Reciprocating Locks is competitive with and often better than the best state-of-the-art scalable spin locks.
翻译:本文提出一种名为"往复锁"的新型互斥锁算法,该算法面向缓存一致性共享内存系统,具备多项优良特性。其门廊到达阶段与释放操作均以常数时间运行。等待线程采用本地自旋策略,且每个线程仅需单个等待元素,与线程当前持有的锁数量无关。尽管本锁不提供严格的先进先出准入机制,但能限制插队行为并具备强抗饥饿特性。该锁结构紧凑、空间高效,且经专门设计可便捷应用于实际通用计算环境,如Linux内核、pthreads或C++。实验表明,该锁在高竞争场景下具有高吞吐量,在无竞争情况下呈现低延迟。往复锁的性能与当前最先进的可扩展自旋锁相比具有竞争力,且通常表现更优。