lock-free
Shared-memory IPC synchronization (lock-free)
Boost Interprocess has support for Shared Memory. Boost Lockfree has a Single-Producer Single-Consumer queue type (spsc_queue). This is basically what you refer to as a circular buffer. Here’s a demonstration that passes IPC messages (in this case, of type string) using this queue, in a lock-free fashion. Defining the types First, let’s define our types: … Read more
Lock-free Progress Guarantees in a circular buffer queue
This queue data structure is not strictly lock-free by what I consider the most reasonable definition. That definition is something like: A structure is lock-free if only if any thread can be indefinitely suspended at any point while still leaving the structure usable by the remaining threads. Of course this implies a suitable definition of … Read more
How can I implement ABA counter with c++11 CAS?
To atomically modify two things at once with a single atomic operation, you need to put them in adjacent memory, e.g. in a two-member struct. Then you can use std::atomic<my_struct> to get gcc to emit lock cmpxchg16b on x86-64, for example. You don’t need inline asm for this, and it’s worth a bit of C++ … Read more