50 likes | 147 Views
Midterm. P 1 : P 2 : P 3 : x = 1 y = 1 z = 1 P 3 ! x - 1 ------------------------------------------------ > P 1 ? z {A1: x = 1 } { C1: z= 0 / x = 1} P 3 ? y < ---------------------- P 2 ! z + 1
E N D
P1: P2: P3: x = 1 y = 1 z = 1 P3 ! x - 1 ------------------------------------------------> P1 ? z {A1: x = 1 } { C1: z= 0 /\ x = 1} P3 ? y <----------------------P2 ! z + 1 {B1: y = 1 /\ z = 0} {C2: z= 0 /\ y = 1} y = y + 1 {B2: y = 2} P2 ? x <-------------- P1 ! y {A2: x = 2/\ y = 2} {B3: y = 2 /\ x = 2}
Producer: Consumer: do do wait for a slot to be empty wait until a slot is non-empty deposit item in the empty slot fetch item from a non-empty slot od od Producer: Consumer: do do in1++ in2++ deposit item in the empty slot fetch item from a non-empty slot out1++ out2++ od od in1 <= out2 + 2 /\ in2 <= out1 in1 <= out2 + out3 + 2 /\ in2 + in3 <= out1
{x = y} co { x = y \/ y = x + 3} < x = x + 2> {x = y + 2 \/ y = x + 1} || { x = y \/ x = y + 2} < y = y + 3> { x + 3 = y \/ x + 1 = y> oc { y = x + 1}