An example demonstrating the ABA problem
40 likes | 67 Views
Learn how the ABA problem can corrupt stacks and how to mitigate it using optimistic non-blocking techniques with practical code illustrations.
An example demonstrating the ABA problem
E N D
Presentation Transcript
An example demonstrating the ABA problem Xinyu Feng University of Science and Technology of China
An Optimistic Non-blocking Stack Top Next Next n n … pop( ){ local done, next, t; done = false; while (!done) { t = Top; if (t==null) return null; next = t.Next; done = CAS(&Top, t, next); } return t; ABA problem leads to corrupted stacks
ABA Problem Top Top Top T2: a = pop(); b = pop(); push(a); T1: pop() { t = Top next = t.Next interrupted resumes CAS(&Top,t,next) succeeds stack corrupted t A next B C Timeline Threads T1 and T2 are interleaved as follows: