-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[atomics.order] p3.3 The initialization to an atomic object is not a atomic operation #641
Comments
I deleted my previous comment because I misread the example. It's possible that there's a defect here, but I'm not sure yet. In this example, there is no observable consequence of the total order; in fact, because no other variables are present, even if both operations were relaxed, the program would have the same behavior as this one that uses sequentially consistent operations. Do you have an example where the observable behavior of the program could actually be affected by the inability to determine which operation is earlier in the total order? |
Related: #38, #96 (comment) |
This issue just gave a minimum example to expose the defect wording. A concrete example could be Peterson's algorithm, when we want to prove the correctness of the algorithm, we should first assume the case where both In this proof, [atomics.order] p3 is necessary, to determine the orders of the seq_cst load and store operations in the single total order where A relevant discussion can be found https://stackoverflow.com/questions/79183275/can-the-combination-of-pure-load-and-a-store-model-the-rmw-operation?noredirect=1#comment139629372_79183275 |
Can you be a bit more concrete about your concern about the total order in Peterson's algorithm? Your original example was formulated in terms of "even if the load operation reads the value stored by the store operation, I cannot prove that the store operation was earlier in the total order". What is the analogous concern in the case of Peterson's algorithm? |
Given this simplified example: std::atomic<bool> a = false;
std::atomic<bool> b = false;
int v = 0;
// thread 1:
a.store(true, seq_cst);
if(b.load(seq_cst)== false){
v = 1; // #1
}
//thread 2:
b.store(true, seq_cst);
if(a.load(seq_cst)== false){
v = 2; // #2
} To prove whether |
Full name of submitter (unless configured in github; will be published with the issue): Jim X
Consider this example:
If the load operation reads the value
0
, how are they ordered in the single total order? According to [atomics.order] p3The initialization to
v
is not an atomic modification as per [atomics.types.operations] p3The initialization(i.e.
X
) precedes the store(i.e.B
) in the modification order ofv
, however,X
is not atomic modification, so, how does p3.3 apply to this case to determine the order of the load and store in the single total order?The text was updated successfully, but these errors were encountered: