本文介绍了比较和交换原子指令如何导致ABA问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近经历了一些用于实现互斥锁的原子指令。其中一些是1)比较和交换2)获取和协议

3)测试和设置4)在多处理器环境下加载链接和存储条件。



[ ]

https ://en.wikipedia.org/wiki/ABA_problem



由于CAS(比较和交换)是原子指令,其他处理器如何与CAS交错。让我们说原子操作不适用于并发的多处理器实现,除非我们可以锁定内存(我不确定这是否正确)。但是如果我们从这个意义上讲,其他原子操作如Fetch和increement,Test和set也导致ABA问题吧?这真令人困惑。我的理解是原子指令不会在中间中断,但是在原子指令期间内存不会被锁定?其他处理器可以读写内存吗?



can有人澄清我的困惑吗?

I have recently gone through some of the atomic instructions which are used to implement mutual exclusive locks. Some of them are 1) compare and swap 2) Fetch and Increement
3) Test and Set 4) Load Link and Store conditional under multiprocessor environment.

https://en.wikipedia.org/wiki/Compare-and-swap[^]
https://en.wikipedia.org/wiki/ABA_problem

Since CAS(compare and swap) is an atomic instruction, how others processors will interleave with CAS. Lets say atomic actions don’t work for multiprocessor implementations of concurrency unless we can lock memory(I am not sure this is right or not).But if we take in that sense , other atomic operations like Fetch and increement, Test and set also cause ABA problem right? This is really confusing. What my understanding is that atomic instructions are not interrupted in the middle, but memory will not be locked during atomic instruction?can other processor read and write the memory?

can someone clarify my confusion?

推荐答案


这篇关于比较和交换原子指令如何导致ABA问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 08:30