Memory model: current status, example
struct Example {
a: AtomicU32,
b: AtomicU32,
}
fn get_sum_with_guard(
v: &SeqLock<SpinLock<Example>>
) -> u32 {
loop {
let guard = v.read();
let sum =
guard.a.load(Ordering::Relaxed) +
guard.b.load(Ordering::Relaxed);
if !guard.need_retry() {
break sum;
}
}
}
403fd4: 14000002 b 403fdc
403fd8: d503203f yield
403fdc: b9400808 ldr w8, [x0, #8]
403fe0: 3707ffc8 tbnz w8, #0, 403fd8
403fe4: d50339bf dmb ishld
403fe8: b9400c09 ldr w9, [x0, #12]
403fec: b940100a ldr w10, [x0, #16]
403ff0: d50339bf dmb ishld
403ff4: b940080b ldr w11, [x0, #8]
403ff8: 6b08017f cmp w11, w8
403ffc: 54ffff01 b.ne 403fdc
404000: 0b090148 add w8, w10, w9
Language