Skip to main content
1 vote
2 answers
272 views

[thread.mutex.requirements.mutex.general] p4 says For purposes of determining the existence of a data race, these behave as atomic operations ([intro.multithread]). The lock and unlock operations on ...
xmh0511's user avatar
  • 7,763
4 votes
3 answers
299 views

I have a struct that contains a std::atomic member: #include <atomic> #include <cstdint> struct Foo { std::atomic<int64_t> value; int64_t age; }; If I allocate memory for ...
Abhishek's user avatar
  • 293
4 votes
0 answers
100 views

I can't find out why clangd (in CLion 2025.3) throw me an error when I write : atomic_int foo; atomic_init(&foo, 0); Clangd: Incompatible pointer types passing 'typeof ((void)0 , *...
Clément Charbonnel's user avatar
0 votes
1 answer
227 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 ...
Johan's user avatar
  • 77.5k
4 votes
3 answers
265 views

Consider this example: #include <atomic> #include <chrono> #include <thread> uint64_t timestamp() { auto now = std::chrono::steady_clock::now().time_since_epoch(); return ...
xmh0511's user avatar
  • 7,763
2 votes
1 answer
66 views

Platform: rp2040 (2 Cortex-M0+ cores, thumbv6m-none-eabi) Main branch of a project removed atomic-polyfill crate due to it being unmaintained. The code I'm rebasing used it for fetch_add. I have to ...
lynx's user avatar
  • 71
3 votes
1 answer
116 views

On RISC-V, A page table entry, which is the size of usize in Rust, has an RSW field, which is 2 bits wide. This field is supervisor defined (e.g. the kernel can use it as it pleases). Could one of ...
CocytusDEDI's user avatar
4 votes
0 answers
519 views

Consider this example: #include <thread> #include <atomic> #include <stream> int main(){ std::ofstream outFile("example.txt", std::ios::out | std::ios::trunc); std::...
xmh0511's user avatar
  • 7,763
9 votes
1 answer
354 views

Let's say I call a memory barrier like: std::atomic_thread_fence(std::memory_order_seq_cst); From the documentation I read that this implement strong ordering among all cores, even for non atomic ...
Mascarpone's user avatar
  • 2,729
1 vote
1 answer
258 views

Consider this example: #include <atomic> #include <iostream> #include <thread> std::atomic<int> canceller = {0}; int main() { auto t1 = std::thread([]() { auto v = ...
xmh0511's user avatar
  • 7,763
3 votes
0 answers
175 views

Consider this example: #include <atomic> #include <iostream> #include <thread> std::atomic<int> canceller = {0}; int main() { auto t1 = std::thread([]() { auto v = ...
xmh0511's user avatar
  • 7,763
1 vote
1 answer
188 views

Consider this example: #include <thread> #include <atomic> int main(){ std::atomic<int> x = 0, y = 0; auto t1 = std::thread([&](){ if(x.load(std::memory_order::relaxed)==...
xmh0511's user avatar
  • 7,763
6 votes
1 answer
178 views

My code is ... fragment1 // compares several regions in D1$ to D1$/D3$ __atomic_fetch_add(&lock,-1,__ATOMIC_ACQ_REL); // stmt A fragment2 // moves several regions from D1$/D3$ to D1$ ...
Henry Rich's user avatar
5 votes
1 answer
394 views

Consider this example: #include <atomic> #include <cassert> #include <thread> int main() { std::atomic<int> strong = {3}; std::atomic<int> weak = {1}; auto t1 ...
xmh0511's user avatar
  • 7,763
2 votes
0 answers
148 views

Consider this example: #include <iostream> #include <atomic> #include <thread> #include <cassert> int main(){ std::atomic<int> val = 1; std::atomic<std::atomic&...
xmh0511's user avatar
  • 7,763

15 30 50 per page
1
2 3 4 5
271