grub-fork/csp/sync.csp

19 lines
649 B
Text
Raw Normal View History

2015-08-13 19:25:18 +00:00
N = 3
2015-08-13 19:41:30 +00:00
channel input, render, up, down, save:{0..N-1}
2015-08-13 18:58:03 +00:00
2015-08-13 19:25:18 +00:00
apply(state, patch) = (state + patch) % N
diff(state1, state2) = (state2 - state1) % N
2015-08-13 19:41:30 +00:00
CLIENT(state, shadow) =
input?new_state -> up!diff(shadow, new_state) -> CLIENT(new_state, shadow)
[] down?patch -> if patch != 0
then render!apply(state, patch) -> CLIENT(apply(state, patch), apply(shadow, patch))
else CLIENT(state, state)
2015-08-13 19:25:18 +00:00
SERVER(state, shadow) =
2015-08-13 19:41:30 +00:00
up?patch -> save!apply(state, patch) -> down!diff(apply(shadow, patch), apply(state, patch))
-> SERVER(apply(state, patch), apply(shadow, patch))
2015-08-13 19:25:18 +00:00
SYSTEM = CLIENT(0, 0) ||| SERVER(0, 0)
2015-08-13 18:58:03 +00:00
assert SYSTEM :[deadlock free [F]]