relaxed-atomics Questions
1
Within one thread, steady_clock::now() is guaranteed to return monotonically increasing values. How does this interact with memory ordering and reads observed by multiple threads?
atomic<int>...
Fifi asked 28/11, 2020 at 4:26
3
Solved
On Visual C++ 2013, when I compile the following code
#include <atomic>
int main()
{
std::atomic<int> v(2);
return v.fetch_add(1, std::memory_order_relaxed);
}
I get back the foll...
Meilhac asked 15/6, 2014 at 22:45
3
A full/general memory barrier is one where all the LOAD and STORE operations specified before the barrier will appear to happen before all the LOAD and STORE operations specified after the barrier ...
Discomfit asked 25/8, 2014 at 1:47
6
Solved
Is there any wording in the standard that guarantees that relaxed stores to atomics won't be lifted above the locking of a mutex? If not, is there any wording that explicitly says that it's kosher ...
Canst asked 3/8, 2017 at 5:4
3
Solved
Suppose I have a thread A that writes to an atomic_int x = 0;, using x.store(1, std::memory_order_relaxed);. Without any other synchronization methods, how long would it take before other threads c...
Schwenk asked 3/5, 2017 at 2:15
3
Solved
After seeing Herb Sutters excellent talk about "atomic weapons" I got a bit confused about the Relaxed Atomics examples.
I took with me that an atomic in the C++ Memory Model (SC-DRF = Sequentiall...
Proportionate asked 9/6, 2013 at 21:29
2
Consider the following code:
struct payload
{
std::atomic< int > value;
};
std::atomic< payload* > pointer( nullptr );
void thread_a()
{
payload* p = new payload();
p->value.st...
Marvamarve asked 20/6, 2015 at 7:57
1
Solved
Imagine N threads running following simple code:
int res = num.fetch_add(1, std::memory_order_relaxed);
where num is:
std::atomic<int> num = 0;
Is it completelly safe to assume, that re...
Strew asked 11/2, 2019 at 21:29
2
Solved
I have a thread that reads from a socket and generates data. After every operation, the thread checks a std::atomic_bool flag to see if it must exit early.
In order to cancel the operation, I set...
Debauchery asked 6/12, 2018 at 14:10
3
Consider the following code snippet taken from Herb Sutter's talk on atomics:
The smart_ptr class contains a pimpl object called control_block_ptr containing the reference count refs.
// Thread A...
Rosenberg asked 24/12, 2014 at 3:42
1
Solved
I am trying to understand the specifics of memory_order_relaxed. I am referring to this link : CPP Reference.
#include <future>
#include <atomic>
std::atomic<int*> ptr {nullptr...
Revisionism asked 1/7, 2015 at 0:40
3
I've written a container for a very simple piece of data that needs to be synchronized across threads. I want the top performance. I don't want to use locks.
I want to use "relaxed" atomics. Partl...
Coriss asked 18/7, 2014 at 18:4
1
© 2022 - 2024 — McMap. All rights reserved.