All Questions
Tagged with concurrency atomic
386
questions
0
votes
1
answer
102
views
Is Intel TBB concurrent vector of doubles lock-free?
I am writing C++ multithreaded code using GCC C++20 on Intel Broadwell XEONs or AMD EPYC 7551s, Intel TBB, and Pagmo2 libraries for optimization problems. If I declare concurrent_vector<double> ...
1
vote
1
answer
122
views
Minimal example of C++ concurrency bug due to one thread loading the value at thread startup
At 6:44 of the talk "Real-time Confessions in C++", the speaker shows buggy code that essentially boils down to:
Thread A writes to an unsynchronized integer called x
Much later, thread B ...
1
vote
0
answers
60
views
Handling Concurrency, Overflow, and Periodic Draining in a Rust HashMap Collection
I am working on a Rust project that involves a complex data structure for concurrently managing key-value pairs across multiple threads. This structure, ConcurrentStorage, is composed of a fixed-size ...
1
vote
0
answers
107
views
Code has different performance depending on which CPU cores it's run on
I'm profiling some code that uses a spinning barrier.
Compiled with:
g++-13 barrier.cc -march=native -o barrier -O3 -Wall -std=c++20
Run with:
taskset -c 0-3 ./barrier
This gives 11,338,408 ...
0
votes
1
answer
57
views
Can you snoop cache coherence traffic to implement linked-load and store-conditional?
I kind of want to implement a form of LL/SC for x86-64 (Saphire/Emerald Rapids most likely). It seems that the cache has all the info needed to do this if, but I need to know when a cache line is ...
0
votes
1
answer
124
views
Why do many implementations of lock-free linked list assume that items are unique in the list?
I am implementing my lock free linked list in C based on this repository and the chapter 9.8 of the book the art of multiprocessor programming. I think they are based on the Harris's paper. And I find ...
2
votes
0
answers
40
views
In the implemention of urcu-qsbr, is there any mechanism to ensure the thread offline/online is visible to writer-thread?
In the implementation of urcu-qsbr, users can use urcu_qsbr_thread_online and urcu_qsbr_thread_offline to mark a critical section for reading.
Here's offline/online
Writers then use ...
0
votes
0
answers
113
views
Lock free queue from Concurrency in Practice
In the push method why do we have old_tail->data.swap(new_data); #5 ? Where am i wrong?
Shouldn't it be p->data.swap(new_data) or p->data=new_data ?
Why are we swapping the new value with ...
0
votes
1
answer
45
views
Bounded atomic counter using mongodb
I was trying to design a simple bounded atomic counter and was wondering if my thinking is correct. Mongodb has an operation called findAndModify(). This operation takes a query. If the query is ...
3
votes
1
answer
206
views
Memory order around atomic operations
I want to build a good mental image about std::memory_order_seq_cst, std::memory_order_relaxed, memory_order_acq_rel.
Imagine your code as a sequence of bricks. Each brick is an operation on some ...
3
votes
1
answer
418
views
Atomic 64 bit counter on ARM 32 bit MCU without locks
On a ARM Cortex M 32 bit, under C, I need to maintain a 64 bit counter. I want to avoid a race condition like:
start:
count = 0x00000000 ffffffff
threadA: increment count_low
count =...
2
votes
3
answers
146
views
How 'fair' is a Standard C++ atomic_flag in waking up threads from a wait() on a notify_one() call
Is there any information about fairness in relation to the sequence in which threads that called wait() on an atomic_flag are woken up when notify_one() is called. Are they woken-up in the exact order ...
2
votes
2
answers
120
views
Is it still atomic if the desired value of std::atomic<T>::compare_exchange_weak is return of a non-atomic operation?
Does head.load()->next break the atomicity here for the std::atomic::compare_exchange_weak used in while(head && !head.compare_exchange_weak(ptr, head.load()->next)); ? I believe it ...
1
vote
1
answer
82
views
What happens if `compare_exchange_weak` is called on a dangling pointer? How is the code in my textbook safe?
I feel like there could about the a dangling pointer in this example implementation of a lock-free stack in C++: Concurrency in Action. The author, Anthony Williams, provides a beginning for the lock-...
2
votes
1
answer
109
views
Clearing the next pointer might not be needed
In the book "C++ Concurrency in Action" by Anthony Williams, when describing the listing "7.9 A lock-free stack using a lock-free std::shared_ptr<>", the author states that ...