Previous | Next --- Slide 55 of 66
Back to Lecture Thumbnails
haofeng

The ABA problem occurs because a given processor thinks the entire stack is not modified as long as top A is the same. However, another processor could pop A, modify the stack, and push A to the stack again, so the processor will be fooled. To solve this problem, this implementation adds a pop_count variable that tracks whether the stack has been modified in addition to the top address. It uses an atomic "double" compare and swap operation which returns true only if both values (top and pop_count) stay the same.

Please log in to leave a comment.