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++。实验表明,该锁在高竞争场景下展现出高吞吐量,在无竞争情况下则具有低延迟。往复锁的性能与当前最先进的可扩展自旋锁相比具有竞争力,且通常表现更优。