On Tue, Jul 5, 2016 at 1:36 AM, Wink Saville <
wi...@saville.com> wrote:
> Dmitry,
>
> I've been using your non-intrusive mpsc fifo in a project and its been
> working well, but now I've reached the point where I'm stressing it with
> many threads on a multicore CPU and I'm running into at least one problem.
> To diagnose the problem I've created another implementation for testing here
> and I'm still seeing a problem. The problem is even though the fifo is NOT
> empty "rmv" infrequently returns NULL!!!
>
> See the README.md file for more information.
>
> Any help much appreciated.
Hello Wink,
This algorithm is not lock-free and is not linearizable.
If a producer is preempted between XCHG and next link update, the
linked list of nodes is temporary broken and all subsequent enqueues
are not visible to consumer until the list is restored.
This condition can be detected by looking at head/tail/next, and then
consumer can spin if necessary.