lock-free Questions

2

Solved

I am reading The Art of Multiprocessor Programming, 2ed and I noticed the following pattern is used to read several Atomic* fields: while (true) { var v1 = atomic1.get(); var v2 = atomic2.get(); ...
Nodical asked 2/6, 2021 at 3:11

3

The following example comes from the MSDN. public class ThreadSafe { // Field totalValue contains a running total that can be updated // by multiple threads. It must be protected from unsynchroni...

2

Solved

I'm developing a multicore, multithreaded software library in which I want to offer update-order preserving lock-free shared memory objects that might span multiple cache lines. Specifically, sup...
Cohort asked 27/8, 2018 at 16:9

3

Solved

From the link: What is the difference between load/store relaxed atomic and normal variable? I was deeply impressed by this answer: Using an atomic variable solves the problem - by using atomics a...
Etter asked 17/12, 2020 at 7:38

4

Solved

Does Java allows output 1, 0? I've tested it very intensively and I cannot get that output. I get only 1, 1 or 0, 0 or 0, 1. public class Main { private int x; private volatile int g; // Execu...
Melburn asked 16/7, 2017 at 22:29

3

Solved

I'm trying to substitute boost::lockfree::queue for std::queue in this file https://github.com/zaphoyd/websocketpp/blob/experimental/examples/broadcast_server/broadcast_server.cpp I've added #incl...
Ezra asked 18/3, 2013 at 1:7

2

Solved

I'd like to write a function that is accessible only by a single thread at a time. I don't need busy waits, a brutal 'rejection' is enough if another thread is already running it. This is what I ha...
Bascom asked 17/11, 2020 at 22:0

2

If T is a C++ fundamental type, and if std::atomic<T>::is_lock_free() returns true, then is there anything in std::atomic<T> that is wait-free (not just lock-free)? Like, load, store, f...
Deedradeeds asked 17/5, 2020 at 9:58

18

I'm in the process of designing a system which connects to one or more stream of data feeds and do some analysis on the data than trigger events based on the result. In a typical multi-threaded pro...
Exhilarate asked 15/5, 2009 at 23:11

2

Solved

In C++ Concurrency in Action, 2e, The author describes a lock-free thread safe linked list implementation. Right now, he is describing the pop() method and how to safely delete the nodes in a sort ...
Exasperation asked 27/5, 2020 at 19:20

4

Solved

I get the feeling this may be a very general and common situation for which a well-known no-lock solution exists. In a nutshell, I'm hoping there's approach like a readers/writer lock, but that do...
Dendrite asked 15/4, 2020 at 20:4

4

I'm trying to implement a lock free multiple producer, multiple consumer queue in C++11. I'm doing this as a learning exercise, so I'm well aware that I could just use an existing open source imple...
Stereotypy asked 7/9, 2014 at 11:8

5

Solved

Also I am doing a c implementation and currently have the structure of the queue: typedef struct queueelem { queuedata_t data; struct queueelem *next; } queueelem_t; typedef struct queue { ...
Hexangular asked 22/5, 2011 at 15:48

2

Solved

I'm studying the difference between mutex and atomic in C++11. As my understanding, mutex is a kind of lock-mechanism, which is implemented based on the OS/kernel. For example, Linux offers ...
Aurelio asked 4/12, 2019 at 12:49

1

Solved

std::atomic_uint64_t writing_ {0}; std::atomic_uint64_t reading_ {0}; std::array<type, size> storage_ {}; bool try_enqueue(type t) noexcept { const std::uint64_t writing { writing_.load(st...
Furriery asked 14/9, 2019 at 16:53

4

Solved

I'm trying to implement a class that uses two threads: one for the producer and one for the consumer. The current implementation does not use locks: #include <boost/lockfree/spsc_queue.hpp> ...
Flaunt asked 9/6, 2014 at 12:6

1

Solved

Assuming that the architecture can support 8 byte scalars in a lock free manner for std::atomic. Why don't standard libraries provide similar specializations for structs that are under 8 bytes? A ...
Hemphill asked 28/4, 2019 at 22:2

2

How can I use boost::lockfree:queue objects? I'm trying to write an application that constructs an object of this class via default constructor, but it gives me an assertion failure inside the boo...
Mizzle asked 26/2, 2014 at 8:48

3

Solved

Swapping two unique_ptrs is not guaranteed to be threadsafe. std::unique_ptr<T> a, b; std::swap(a, b); // not threadsafe Since I need atomic pointer swaps and since I like the ownership ha...
Redness asked 17/3, 2013 at 12:43

2

Solved

I have been looking at a lock free single producer/single consumer circular buffer on this website when I couldn't figure out why a specific memory barrier was needed. I have carefully read a hundr...
Ist asked 19/1, 2019 at 14:47

4

Solved

I've got a single writer which has to increment a variable at a fairly high frequence and also one or more readers who access this variable on a lower frequency. The write is triggered by an exter...
Thespian asked 10/1, 2019 at 9:51

3

Solved

I had 2 questions regarding the std::shared_ptr control block: (1) Regarding size: How can I programatically find the exact size of the control block for a std::shared_ptr? (2) Regarding logic: A...
Con asked 26/11, 2018 at 3:45

2

Solved

Until now I was using std::queue in my project. I measured the average time which a specific operation on this queue requires. The times were measured on 2 machines: My local Ubuntu VM and a remo...
Vermin asked 21/4, 2017 at 10:57

3

Solved

In C#, volatile keyword ensures that reads and writes have acquire and release semantics, respectively. However, does it say anything about introduced reads or writes? For instance: volatile Thin...

4

I am looking for a method to implement lock-free queue data structure that supports single producer, and multiple consumers. I have looked at the classic method by Maged Michael and Michael Scott (...
Presumptive asked 23/4, 2010 at 22:25

© 2022 - 2024 — McMap. All rights reserved.