AIR: linear atomic<T> (AtomicScalar), atomic.new/take/load/store/RMW/ cmpxchg (two results)/fence with explicit orderings; feature atomics published. Verifier: ordering tables (E4201), ordinary access (E4202), effects [atomic] / [atomic, atomic.weak], linearity, take while lent (E4101, also for mutex.take). Interpreter: timestamped message machine (src/interp/weak.zig); views travel through spawn/join, channels, mutexes, close and cancel; seq_cst reads the latest message and programs without weak reads make no extra draw (existing records unchanged). aji explore: exhaustive exploration that branches only before visible operations. Litmus: 20/20 tests give exactly the oracle's sets; differential test (1500 random programs) found no unsound outcome. .aji layer 10, Quick Reference atomics, source coverage 67/67, audit report atomic_operations. AIR bundle +5.9 %, QUICK.md +0.5k.
41 lines
972 B
Rust
41 lines
972 B
Rust
// Release/acquire publication: a reader that sees the flag sees the data.
|
|
// expect: run
|
|
// schedules: 30
|
|
// quantum: 1
|
|
// result: 1
|
|
// phase: 6
|
|
// spec: docs/spec/15-source-language.md
|
|
module demo.publication
|
|
|
|
fn publish(data: ref<atomic<u64>>, ready: ref<atomic<bool>>) -> u8
|
|
effects [atomic, atomic.weak]
|
|
{
|
|
atomic.store(data, 42u64, relaxed);
|
|
atomic.store(ready, true, release);
|
|
0u8
|
|
}
|
|
|
|
fn main() -> u64
|
|
effects [atomic, atomic.weak, task.spawn, task.wait]
|
|
{
|
|
let data = atomic.new(0u64);
|
|
let ready = atomic.new(false);
|
|
var ok: u64 = 1;
|
|
{
|
|
ref d = data;
|
|
ref r = ready;
|
|
scope s {
|
|
let p = task.spawn(s, publish, d, r);
|
|
if atomic.load(r, acquire) {
|
|
if atomic.load(d, relaxed) != 42 {
|
|
ok = 0;
|
|
}
|
|
}
|
|
let rp = task.join(move p);
|
|
}
|
|
}
|
|
let v = atomic.take(move data);
|
|
let f = atomic.take(move ready);
|
|
ok
|
|
}
|