You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How could I know in which order the code have been executed?
Does the ones printed with the above println! macro represent the exact order which have been executed?
How could the value of P1's flag0_curr contain false even after flag0 has been written as true by P0?
Does the result mean that only P0's turn has been correctly stored while other stores have not been reflected?
The text was updated successfully, but these errors were encountered:
Correctness of Peterson's algorithm assumes that there is a total order among the instructions. This is not true in weak memory models such as C/C++/Rust's, because for example a load() can read from a "stale" store(). To make this work as expected, you will need to recover sequential consistency by passing SeqCst instead of Acquire and Release.
But unfortunately, due to technical limitations, Loom does not understand SeqCst in load(), store(), etc. methods of Atomic* types. However, Loom does support fence(SeqCst). See #180 for details.
For Peterson's algorithm, you can simply insert fence(SeqCst) between all the accesses.
I've used the loom to test peterson's algorithm.
Peterson's algorithm does not seem to provide mutual exclusion with the below memory ordering.
The below is the result.
How could I know in which order the code have been executed?
Does the ones printed with the above
println!
macro represent the exact order which have been executed?How could the value of P1's
flag0_curr
containfalse
even after flag0 has been written astrue
by P0?Does the result mean that only P0's
turn
has been correctly stored while other stores have not been reflected?The text was updated successfully, but these errors were encountered: