Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
0 votes
2 answers
152 views

I am trying to implement a lock-free multiple-producer-single-consumer ring buffer in C++. Here is the full definition and the test code. #include <iostream> #include <memory> #include <...
Advice
0 votes
4 replies
147 views

I recently had an interview where I was asked to show how to prevent race conditions in C or C++ between two threads operating on shared data. I used a mutex as follows : pthread_mutex_t mutex; int ...
2 votes
1 answer
119 views

I'm trying to learn CUDA programming, and recently I have been working on the lectures in this course: https://people.maths.ox.ac.uk/~gilesm/cuda/lecs/lec3.pdf, where they discussed the atomicCAS ...
2 votes
2 answers
513 views

We are currently evaluating 128-bit atomic operation support across platforms and compilers, and I wanted to confirm the level of support available in Clang specifically. Our reference point is the ...
0 votes
0 answers
106 views

I am trying to solve the much talked about problem of transferring money from one account to another in a thread safe manner, given that the accounts exist in memory only. I was able to easily solve ...
1 vote
2 answers
792 views

Assuming we have just 1 cpu core and for the sake of example given the following CAS loop (in Java language, took it from here), although the question is about CAS loop in general not this code in ...
-2 votes
1 answer
118 views

I am getting into a race condition with 2 threads while using atomic CAS. std::atomic<int> turn(0); int free = 0; void Work(int pid){ while(true){ if(turn.compare_exchange_strong(...
1 vote
2 answers
99 views

I'm working on a lock-free stack implementation using C++ and CAS (compare_exchange_strong/compare_exchange_weak). The implementation seems to work fine on modern Linux systems but fails on Windows ...
5 votes
2 answers
154 views

I was learning about C++ memory sequence, and I found this code in Unreal Engine5. My question is why not call compare_exchange_strong() directly instead of load() first? FHttpRequest* GetFreeRequest()...
2 votes
1 answer
142 views

I have a code where i want to CAS atomic struct (Update) and it returns false. That happens with expected and atomic structs having same field values (tested with one thread). I went to cpprefernce ...
5 votes
0 answers
174 views

Consider the following interaction between T1 and T2. Can it happen that T2 will miss the notification from T1 and will suspend? In other words, can it happen that compare_exchange_weak will succeed ...
Roman's user avatar
  • 1,523
4 votes
1 answer
121 views

Intel official documentation says: The ZF flag is set if the values in the destination operand and register AL, AX, or EAX are equal; otherwise it is cleared. The CF, PF, AF, SF, and OF flags are set ...
1 vote
1 answer
141 views

I have a block of code where std::atomic<std::weak_ptr<T>> doesn't behave the way I would have expected if the underlying weak pointer is expired: std::atomic<std::weak_ptr<Widget>...
0 votes
0 answers
63 views

I'm doing the parallel version of Bellman-Ford algorithm in c++ using std::atomic This is my main function executed in multiple threads void calculateDistances(size_t start, size_t end, const Graph&...
0 votes
1 answer
148 views

After learning std::atomic and std::memory_order I wanted to experiment with writing a thread safe shared_ptr<T> and weak_ptr<T> implementation using atomics based on Microsoft Blog: ...

15 30 50 per page
1
2 3 4 5
...
27

AltStyle によって変換されたページ (->オリジナル) /