Issue There are three different types of "lock-free" algorithms. The definitions given in Concurrency in Action are: Obstruction-Free: If all other threads are paused, then any given thread will complete its operation in a bounded number of steps. Lock-Free: If
Continue readingTag: lock-free
[SOLVED] Lock-free Progress Guarantees in a circular buffer queue
Issue Anecdotally, I’ve found that a lot of programmers mistakenly believe that “lock-free” simply means “concurrent programming without mutexes”. Usually, there’s also a correlated misunderstanding that the purpose of writing lock-free code is for better concurrent performance. Of course, the
Continue reading[SOLVED] Truly Lock-free MPMC Ring Buffer? Threads able to assist each other to avoid blocking?
Issue This question is inspired by Lock-free Progress Guarantees. The code shown is not strictly lock-free. Whenever a writer thread is suspended when the queue is not empty or not full, the reader threads returned false, preventing the whole data
Continue reading[SOLVED] Is a memory barrier required to read a value that is atomically modified?
Issue Given the following: class Foo { public: void Increment() { _InterlockedIncrement(&m_value); // OSIncrementAtomic } long GetValue() { return m_value; } private: long m_value; }; Is a memory barrier required for the read of m_value? My understanding is that _InterlockedIncrement
Continue reading[SOLVED] Are memory orders for each atomic correct in this lock-free SPSC ring buffer queue?
Issue I have a ring buffer that looks like: template<class T> class RingBuffer { public: bool Publish(); bool Consume(T& value); bool IsEmpty(std::size_t head, std::size_t tail); bool IsFull(std::size_t head, std::size_t tail); private: std::size_t Next(std::size_t slot); std::vector<T> buffer_; std::atomic<std::size_t> tail_{0}; std::atomic<std::size_t> head_{0};
Continue reading[SOLVED] In what circumstances lock free data structures are faster than lock based ones?
Issue I’m currently reading C++ Concurrency in Action book by Anthony Williams and there are several lock free data structures implementations. In the forward of the chapter about lock free data structures in the book Anthony is writing: This brings
Continue reading[SOLVED] CPU Registers and Cache Coherence
Issue What’s the relation between CPU registers and CPU cache when it comes to cache coherence protocols such as MESI? If a certain value is stored in the CPU’s cache, and is also stored in a register, then what will
Continue reading[SOLVED] Synchronization with "versioning" in c++
Issue Please consider the following synchronization problem: initially: version = 0 // atomic variable data = 0 // normal variable (there could be many) Thread A: version++ data = 3 Thread B: d = data v = version assert(d !=
Continue reading