Load-link/store-conditional
此條目需要擴充。 (2017年11月22日) |
此條目需要精通或熟悉相关主题的编者参与及协助编辑。 (2017年11月22日) |
在電腦科學中,load-linked/store-conditional(LL/SC),也會被稱作load-reserved/store-conditional (LR/SC),load-link与store-conditional (LL/SC)是一对用于并发同步访问内存的CPU指令。Load-link返回内存位置处的当前值,随后的store-conditional在该内存位置处保存新值(如果从load-link后没有被修改)。这被用于实现无锁算法与read-modify-write原子操作。
历史
LL/SC最初是Jensen, Hagensen, Broughton在勞倫斯利佛摩國家實驗室为S-1 AAP multiprocessor (页面存档备份,存于互联网档案馆)而设计。
实现
LL/SC指令被下述架构支持:
- Alpha: ldl_l/stl_c , ldq_l/stq_c
- PowerPC: lwarx/stwcx , ldarx/stdcx
- MIPS架構: ll/sc
- ARM架構: ldrex/strex (ARMv6 , v7), ldxr/stxr (ARM version 8)
- RISC-V: lr/sc
LL/SC的硬件实现典型地不允许嵌套LL/SC对。[1] 嵌套的LL/SC机制用于提供MCAS原语(多字Compare-And-Swap,字可以是分布的)。[2] 2013年Trevor Brown, Faith Ellen, Eric Ruppert软件实现了多地址LL/SC扩展。[3]这被用来优化二叉搜索树。[4]
参见
参考文献
- ^ Larus, James R.; Rajwar, Ravi. Transactional Memory. Morgan & Claypool. 2007: 55. ISBN 978-1-59829-124-7.
- ^ Fraser, Keir. Practical lock-freedom (PDF) (技术报告). University of Cambridge Computer Laboratory: 20. February 2004 [2017-11-22]. UCAM-CL-TR-579. (原始内容存档 (PDF)于2020-11-12).
- ^ Brown, Trevor; Ellen, Faith; Ruppert, Eric. Pragmatic primitives for non-blocking data structures (PDF). PODC '13 Proceedings of the 2013 ACM symposium on Principles of distributed computing. ACM. 2013: 13–22 [2017-11-22]. ISBN 978-1-4503-2065-8. doi:10.1145/2484239.2484273. (原始内容 (PDF)存档于2015-02-03). See also slides (页面存档备份,存于互联网档案馆)
- ^ Brown, Trevor; Ellen, Faith; Ruppert, Eric. A general technique for non-blocking trees (PDF). PPoPP '14 ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming. ACM. 2014: 329–342 [2017-11-22]. ISBN 978-1-4503-2656-8. doi:10.1145/2555243.2555267. (原始内容存档 (PDF)于2019-10-24).
- Jensen, Eric H.; Hagensen, Gary W.; Broughton, Jeffrey M. A New Approach to Exclusive Data Access in Shared Memory Multiprocessors (PDF) (技术报告). Lawrence Livermore National Laboratory. November 1987 [2017-11-22]. UCRL-97663. (原始内容 (PDF)存档于2017-02-02).
- Bruner, John D.; Hagensen, Gary W.; Jensen, Eric H.; Pattin, Jay C.; Broughton, Jeffrey M. Cache Coherence on the S-1 AAP (PDF) (技术报告). Lawrence Livermore National Laboratory. 11 November 1987 [2017-11-22]. UCRL-97646. (原始内容 (PDF)存档于2017-02-02).
- Detlefs, D.; Martin, P.; Moir, M.; Steele, Jr., Guy L. Lock-free reference counting. PODC '01 Proceedings of the twentieth annual ACM symposium on Principles of distributed computing. ACM. 2001: 190–9. ISBN 1-58113-383-9. doi:10.1145/383962.384016.
- Reinholtz, Kirk. Atomic Reference Counting Pointers. C/C++ Users Journal. December 2004.[永久失效連結]
- Sites, R. L. Alpha AXP architecture. Comm. ACM. February 1993, 36 (2): 33–44. doi:10.1145/151220.151226.