Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ABA in lock free algorithms

I understand the ABA problem. But the thing which I am unable to comprehend is: they say that in languages having automatic garbage collection it may not exhibit. So my questions are:

  • How automatic garbage collection prevents ABA problem in happening?
  • Is it possible in java and if yes, how?
  • Is it possible to prevent this from happening?
like image 421
Trying Avatar asked Oct 29 '13 14:10

Trying


People also ask

What is ABA problem in concurrency?

A common problem in concurrency is the so-called ABA problem. That means you read a value twice and each time it returns the same value A. Therefore you conclude that nothing changed in between.

What is locking free method?

An algorithm is lock-free if infinitely often operation by some processors will succeed in a finite number of steps. For instance, if N processors are trying to execute an operation, some of the N processes will succeed in finishing the operation in a finite number of steps and others might fail and retry on failure.

What is ABA in computer?

ABA Computer Abbreviation. 1. ABA. Address Book Archive. Technology, IT, Information Technology.

How do you implement lock-free algorithm in C++?

A first variant of this algorithm is possible using a lock-free technique, whereby the slist is accessed through an atomic variable. What this allow is for the producer to create all of its items at once, then publish them to the consumer by atomically setting the queue's head. Consumers remain the same.


1 Answers

  • When automatic garbage collection is enabled ,no two objects can be allocated with the same reference and co-exist at the same time,that's because as long as there is a reference count greater then 0 the reference itself will not be released and re-used.

    so you cannot "switch" the reference contents to "point" for different object while someone still has the old reference.

like image 105
shaydel Avatar answered Sep 30 '22 20:09

shaydel