Skip to main content
  1. About
  2. Stack Internal
The 2026 Annual Developer Survey is live— take the Survey today!
Filter by
Sorted by
Tagged with
Filter by Employee ID
Best practices
0 votes
2 replies
101 views

I am building some concurrent Rust code and trying to optimize a few small pieces of shared state using atomics such as AtomicBool. One thing I am still struggling to understand is when Rust code ...
Score of 0
0 answers
145 views

I'm using a multi-platform API which uses pthread_mutex_t for scoped locks, to ensure things don't do what they shouldn't be doing. I want to use the scoped lock methods provided by this API, if ...
Score of 0
1 answer
237 views

Have some multi-threaded code that needs to do some locking. The details of that do not matter here. But I do the canonical do { ... } while (!CAS) loop. To keep the code concise I want to add a wait ...
  • reputation score 77643
Score of 0
2 answers
169 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
167 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 ...
  • reputation score 4189
Score of 2
1 answer
139 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 ...
  • reputation score 712
Score of 2
2 answers
913 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 ...
  • reputation score 293
Score of 1
0 answers
126 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 ...
Score of 1
2 answers
1395 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 ...
Score of -2
1 answer
130 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(...
  • reputation score 39
Score of 1
2 answers
105 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 ...
Score of 5
2 answers
181 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()...
  • reputation score 63
Score of 2
1 answer
148 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 ...
Score of 5
0 answers
194 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 ...
  • reputation score 1523
Score of 4
1 answer
131 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 ...
  • reputation score 151

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

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