Hello
ludob wrote:
>TLockfree_MPMC.pop:
>CAS isn't thread safe at all. Exemple: thread 1 wants to set head to 5, it pushes >5 on the stack and gets pre-empted by thread 2. Thread 2 pops from the fifo, >head is still 4, and gets same data as thread 1 (=problem 1). Pops a few other >items and leaves head at 15. Thread 1 is back and continues (remember 5 on >the stack), continues with CAS and head is 5 (problem 2).
It can not get the same data because there is a lock in the CAS and if
CAS have changed the CAS in thread2 will fail and thread 2 have to spin another time and there is no problem.
Amine Moulay Ramdane.