Look at the wiki today and see a mention of what's going to fall into race condition & ABA problem. Ah, I have not heard of Aba Ah, then I went to search for a bit, as follows:
Http://www.bubuko.com/infodetail-317006.html
"SpinLock spin Lock, CAS operation (Compare & Set) ABA problem"
The ABA is explained as follows:
The so-called ABA (see Wikipedia's ABA Entry), the problem is basically like this:
- Process P1 reads a value of a in a shared variable
- P1 was preempted, process P2 executed.
- P2 the value of the shared variable from a to B, and then to a, at this time by P1 preemption.
- P1 returned to see that the value in the shared variable was not changed, and then continued.
The ABA problem is most likely to occur in the lock free algorithm, with CAs taking the brunt because CAS determines the address of the pointer.
If this address is reused, the problem is huge.
You have a suitcase full of money at the airport, here comes a hot sexy beauty, then she is very warm tease you, and while you are not aware of the time,
Put a bag in an identical suitcase with your full money box, and then leave, you see your suitcase is still there, so carry a suitcase to catch a plane.
This is the problem of ABA.
The CAS operation consists of three operands-the memory location (V), the expected original value (A), and the new value (B).
If the value of the memory location matches the expected original value, the processor automatically updates the location value to the new value.
-aba noun