omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / host / tests / cpufence.om
| 1 | note cpufence / cpurelax (#939): store the payload, publish it with a fence, then set the flag. A bounded |
| 2 | note poll spins with cpurelax. Values live in registers across both words must survive them. Exit 42. |
| 3 | global data ulong 4 |
| 4 | global flag ulong 1 |
| 5 | fn publish v ulong to ulong |
| 6 | put data 2 v |
| 7 | cpufence |
| 8 | put flag 0 v |
| 9 | ret get flag 0 |
| 10 | end |
| 11 | fn main to int |
| 12 | a = ulong 11 |
| 13 | b = ulong 22 |
| 14 | put data 0 a |
| 15 | put data 1 b |
| 16 | cpufence |
| 17 | put flag 0 1 |
| 18 | n = ulong 0 |
| 19 | while lt n 3 |
| 20 | cpurelax |
| 21 | n = add n 1 |
| 22 | end |
| 23 | cpufence |
| 24 | if ne get flag 0 1 |
| 25 | ret 1 |
| 26 | end |
| 27 | if ne add get data 0 get data 1 33 |
| 28 | ret 2 |
| 29 | end |
| 30 | if ne publish 7 7 |
| 31 | ret 3 |
| 32 | end |
| 33 | if ne get data 2 7 |
| 34 | ret 4 |
| 35 | end |
| 36 | if ne add a b 33 |
| 37 | ret 5 |
| 38 | end |
| 39 | if ne n 3 |
| 40 | ret 6 |
| 41 | end |
| 42 | ret 42 |
| 43 | end |