lock-free Questions

1

Solved

My test code is as below, and I found that only the memory_order_seq_cst forbade compiler's reorder. #include <atomic> using namespace std; int A, B = 1; void func(void) { A = B + 1; at...
Expunge asked 13/11, 2016 at 22:7

3

Solved

I have a class that stores the latest value of some incoming realtime data (around 150 million events/second). Suppose it looks like this: class DataState { Event latest_event; public: //pus...

1

Solved

I am implementing a lock-free queue based on this algorithm, which uses a counter to solve the ABA problem. But I don't know how to implement this counter with c++11 CAS. For example, from the algo...
Argon asked 16/8, 2016 at 20:44

1

Solved

I'm looking for Composable operations - it fairly easily to do using transactional memory. (Thanks to Ami Tavory) And it easily to do using locks (mutex/spinlock) - but it can lead to deadlocks -...
Semitropical asked 11/8, 2016 at 11:21

6

Solved

I read somewhere (can't find the page anymore) that lock free data structures are more efficient "for certain workloads" which seems to imply that sometimes they're actually slower or the gain from...
Veda asked 18/10, 2009 at 19:37

1

Solved

In the answer StoreStore reordering happens when compiling C++ for x86 @Peter Cordes has written For Acquire/Release semantics to give you the ordering you want, the last store has to be the ...
Augusto asked 18/7, 2016 at 13:15

1

Solved

while(true) { int x(0), y(0); std::thread t0([&x, &y]() { x=1; y=3; }); std::thread t1([&x, &y]() { std::cout << "(" << y << ", " <<x <<")" &lt...
Literatim asked 16/7, 2016 at 20:58

4

I have just seen Herb Sutter's talk: C++ and Beyond 2012: Herb Sutter - atomic<> Weapons, 2 of 2 He shows bug in implementation of std::shared_ptr destructor: if( control_block_ptr->refs.fe...
Sapless asked 14/2, 2013 at 17:54

1

Solved

In the process of trying to understand how to deal with lock free code, I attempted to write a single consumer/single producer lock free queue. As always, I checked papers, articles, and code, espe...
Linalool asked 22/3, 2016 at 15:57

1

Solved

I have something like: if (f = acquire_load() == ) { ... use Foo } and: auto f = new Foo(); release_store(f) You could easily imagine an implementation of acquire_load and release_store that...
Nanice asked 19/2, 2016 at 23:21

1

I have been reading Memory Barriers: A Hardware View For Software Hackers, a very popular article by Paul E. McKenney. One of the things the paper highlights is that, very weakly ordered processor...

2

(Assume 64-bit x86-64 architecture and Intel 3rd/4th generation CPU) Here is a lock-free implementation for a stack from Concurrency in Action book, page 202: template<typename T> class loc...
Menado asked 31/5, 2014 at 15:33

6

Solved

We are developing a network application based C/S, we find there are too many locks adding to std::map that the performance of server became poor. I wonder if it is possible to implement a lock-f...
Andesine asked 15/1, 2013 at 13:24

3

I'm wondering if it is possible to create a lock-free, thread-safe shared pointer for any of the "common" architectures, like x64 or ARMv7 / ARMv8. In a talk about lock-free programming at cppcon2...
Induplicate asked 7/7, 2015 at 18:59

3

Solved

I can't find a semantic difference between lock-based and lock-free atomics. So far as I can tell, the difference is semantically meaningless as far as the language is concerned, since the language...
Giavani asked 21/7, 2015 at 5:28

2

Solved

What does it mean to make a dynamic array thread-safe and concurrent? Say, for example, std::vector. Two threads may want to insert at the same position. No synchronization needed as it will be d...
Horizontal asked 30/6, 2015 at 7:7

5

Solved

To perform lock-free and wait-free lazy initialization I do the following: private AtomicReference<Foo> instance = new AtomicReference<>(null); public Foo getInstance() { Foo foo = ...

2

Solved

From C++ Concurrency in Action: difference between std::atomic and std::atomic_flag is that std::atomic may not be lock-free; the implementation may have to acquire a mutex internally in order t...
Rostand asked 15/5, 2015 at 9:54

3

I'm using boost spsc_queue to move my stuff from one thread to another. It's one of the critical places in my software so I want to do it as soon as possible. I wrote this test program: #include &...
Destinee asked 8/4, 2015 at 6:42

1

Solved

So we're using a version of boost which is pretty old for now, and until upgrading I need to have an atomic CAS operation in C++ for my code. (we're not using C++0x yet either) I created the follo...

1

Solved

Most CPU architectures will re-order stores-load operations, but my question is why? My interpretation of a store-load barrier would look like this: x = 50; store_load_barrier; y = z; Furthermo...

1

AFAIK Leslie Lamport has stated the following: ... the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations o...
Bk asked 14/11, 2014 at 16:0

2

Solved

In some articles about algorithm, some use the word lockfree, and some use lockless. What's the difference between lockless and lockfree? Thanks! Update http://www.intel.com/content/dam/www/publi...
Nicky asked 9/12, 2013 at 9:30

9

Solved

Asking this question with C# tag, but if it is possible, it should be possible in any language. Is it possible to implement a doubly linked list using Interlocked operations to provide no-wait lo...
Ferdinande asked 11/5, 2009 at 19:57

2

Solved

Hazard pointers are a technique for safely reclaiming memory in lock-free code without garbage-collection. The idea is that before accessing an object that can be deleted concurrently, a thread se...

© 2022 - 2024 — McMap. All rights reserved.