- queue with capacity for 3 elements
- two producers p1, p2 and one consumer c1
- queue contains one element "x" at the first position
- Thread p1 wants to insert an element "Y"
front
|
[x, ., .]
|
back
---> Result is that the queue is not full. p1 continues trying to insert an element
front
|
[x, a, b]
|
back
front
|
[., a, b]
|
back
front
|
[c, a, b]
|
back
---> Succeeds, because back (again) contains the value 0
front
|
[c, a, b]
|
back
ERROR: The queue pointers now show that the list only contains one element "a"
In order to prevent this kind of ABA-Problem, it would be required to test&set both "front" and "back" simultaineously. Since this isn't possible using C++ Atomics, I think that the task has no correct solution.