------------------------------------------------------------------------------- Mohamed G. Gouda CS 356 Summer 2007 Midterm 3 Solution ------------------------------------------------------------------------------- 1. (10 Points): Statement S.0: if b=1 -> up := true [] b=0 -> up := false fi; send chk(b) to p[i +n 1] Statement S.1: up := false Statement S.2: up := true; send chk(1) to p[1] Statement S.3: up := false; send chk(0) to p[1] ------------------------------------------------------------------------------- 2. (10 Points): Statement RTMSG: if i != x ^ j != 0 ^ up[prs[0]] -> send data(x,y) to p[prs[0]] [] i != x ^ j != 0 ^ ~up[prs[0]] -> {non reach.} skip [] i != x ^ j = 0 ^ up[x,0] -> send data(x,y) to p[x,0] [] i != x ^ j = 0 ^ ~up[x,0] -> {non reach.} skip [] i = x ^ j != y ^ up[prs[y]] -> send data(x,y) to p[prs[y]] [] i = x ^ j != y ^ ~up[prs[y]] -> {non reach.} skip [] i = x ^ j = y -> {arrived} skip fi -------------------------------------------------------------------------------