Load-link/store-conditional

在電腦科學中,load-linked/store-conditional(LL/SC),也會被稱作load-reserved/store-conditional (LR/SC)load-linkstore-conditional (LL/SC)是一对用于并发同步访问内存的CPU指令。Load-link返回内存位置处的当前值,随后的store-conditional在该内存位置处保存新值(如果从load-link后没有被修改)。这被用于实现与read-modify-write原子操作。

历史
LL/SC最初是Jensen, Hagensen, Broughton在勞倫斯利佛摩國家實驗室为[http://forum.stanford.edu/wiki/index.php/S-1_project 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对。 嵌套的LL/SC机制用于提供MCAS原语(多字Compare-And-Swap,字可以是分布的)。 2013年Trevor Brown, Faith Ellen, Eric Ruppert软件实现了多地址LL/SC扩展。这被用来优化二叉搜索树。

参见
*
*事务内存(Transactional memory)

参考文献
*
*
*
*
*

评论 (0)

  • 还没有评论,来抢沙发吧。