Questions tagged [aba]

The A-B-A problem refers to the situation where a variable is changed from A to B and then back to A again. For another thread it is thus not possible to detect that the variable was indeed changed.

The following diagram illustrates A-B-A problem: enter image description here

12 questions
7
votes
1 answer

How can I implement ABA counter with c++11 CAS?

I am implementing a lock-free queue based on this algorithm, which uses a counter to solve the ABA problem. But I don't know how to implement this counter with c++11 CAS. For example, from the algorithm: E9: if CAS(&tail.ptr->next, next,
BugRepairMan
  • 221
  • 2
  • 9
6
votes
1 answer

Is this hazard pointer example flawed because of ABA issue?

In the book C++ Concurrency in Action, the author gave an example of using hazard pointer to implement a lock-free stack data structure. Part of the code is as follows: std::shared_ptr pop() { std::atomic&…
Lingxi
  • 14,579
  • 2
  • 37
  • 93
4
votes
1 answer

Why does automatic garbage collection eliminate ABA problems?

I have investigated ABA problem in Concurrency in practice book, in Wikipedia and I have read following post As I understand the root cause of ABA problem that in algoritm we check that state same as was before but algorithm implies that state was…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
1
vote
1 answer

Managing cancellation of an asynchronous task

I am using the Web Speech API to read out an array of words with a short delay between each one (a spelling test for my son!). I have defined an async function to speak a single word and used setTimeout() to delay the following word by 5 seconds.…
1
vote
2 answers

Is there anything like Java's AtomicStampedReference in C++?

I am learning lock-free structure, and I noticed an ABA problem. I think Java's AtomicStampedReference can solve this problem. So, is there anything similar in C++ that can solve this?
nick huang
  • 443
  • 4
  • 12
1
vote
1 answer

Lock Free stack implementation idea - currently broken

I came up with an idea I am trying to implement for a lock free stack that does not rely on reference counting to resolve the ABA problem, and also handles memory reclamation properly. It is similar in concept to RCU, and relies on two features:…
valenumr
  • 85
  • 5
1
vote
0 answers

Solve ABA concurrency issue using C++ prior to 20

At CppCon 2014, Herb Sutter described a neat solution to the ABA problem using atomic shared ptr. A summary of this solution can be found at the bottom of this article. However, the partial specialization of atomic on shared_ptr is a feature of the…
Lingxi
  • 14,579
  • 2
  • 37
  • 93
0
votes
0 answers

I built a stack using CAS, is it thread-safe?

I'm using std::atomic to create a stack that utilizes CAS. To solve the ABA problem, I used tagged pointer. The code is shown below. template union tagged_ptr { struct { std::uint64_t tag : 12, ptr : 52; }; …
tongstar
  • 35
  • 5
0
votes
2 answers

Is ABA relevant for push/insertion operations when using the CAS idiom?

The following pseudo-code is taken from http://15418.courses.cs.cmu.edu/spring2013/article/46 while (1) { n->next = p->next; Node *old_next = p->next; if (compare_and_swap(&p->next, old_next, n) == old_next) return; } This is the push…
24n8
  • 1,898
  • 1
  • 12
  • 25
0
votes
1 answer

ABA Race Condition

I'm concerned about nested pointers and access, specifically whether there is a way to avoid this ABA problem when dealing with a lock-free node based tree structure. My concern is the following: Does the standard make guarantees about this and is…
David Ledger
  • 2,033
  • 1
  • 12
  • 27
0
votes
2 answers

ABA with Clojure Software Transactional Memory

I was wondering wether Clojure has a built in solution for the ABA-problem. I was creating an example that shows this problem, but somehow Clojure detects the changes. Is this because Clojure's transactions compare the references and not the…
user7057391