------------------------------------------------------------------ Mohamed G. Gouda CS 356 Fall 2005 Solution to Midterm 2 ------------------------------------------------------------------ 1. process p inp m { m>0 } var conp : boolean, { initially, false } cansnd : 0 .. m, with : 0 .. n-1 par i : 0 .. n-1 begin timeout ~conp ^ (#ch.p.q[i]+#ch.q[i].p=0) -> send crqst to q[i] [] rcv crply from q[i] -> if conp -> send drqst to q[i] [] ~conp -> conp,cansnd,with := true,m,i fi [] conp -> if cansnd>0 -> send data to q[with]; cansnd := cansnd -1 [] true -> send drqst to q[with]; cansnd := 0 fi [] rcv drply from q[i] -> if with =i -> conp := false [] with!=i -> skip fi end ------------------------------------------------------------------ 2. length of longest elementary corruption burst that can be detected = if n = 1 -> 1 [] n > 1 -> (m+1)*n fi ------------------------------------------------------------------