Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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> ...
Phil's user avatar
  • 21
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 ...
michaeljan's user avatar
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 ...
LKB's user avatar
  • 159
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 ...
David Frank's user avatar
  • 6,062
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 ...
Jason Nordwick's user avatar
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 ...
J-w's user avatar
  • 3
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 ...
Zhipeng Teng's user avatar
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 ...
nvn's user avatar
  • 159
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 ...
broadbear's user avatar
  • 674
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 ...
user2961927's user avatar
  • 1,654
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 =...
SRobertJames's user avatar
  • 8,929
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 ...
Walter's user avatar
  • 159
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 ...
Ekrem Kılıç's user avatar
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-...
teddy's user avatar
  • 125
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 ...
Maurice's user avatar
  • 31

15 30 50 per page
1
2 3 4 5
26