------------------------------------------------------------------------------- Mohamed G. Gouda CS 356 Spring 2008 Homework 2 ------------------------------------------------------------------------------- 1. (Detecting Message Reorder: 5 points) Consider a protocol where a process p continuously sends blocks of three messages each to process q. The three messages in a block are as follows: first(integer), second(integer), and third(integer). Process p is specified as follows: process p var data : array [integer] of integer, i : integer begin true -> send first(data[i]) to q; i := i+1; send second(data[i]) to q; i := i+1; send third(data[i]) to q; i := i+1; end Design process q such that q receives the sent messages and stores their integer fields in an infinite array rcvd in order. Process q should tolerate message reorder, assuming that every sent message can take part in at most one occurrence of reorder with an adjacent message in the channel from process p to process q. ------------------------------------------------------------------------------- 2. (5 points) Consider a protocol that consists two process arrays p[i : 0..x-1] and q[j : 0..y-1]. Each p[i] can establish a connection to any q[j] using the connection protocol in Section 6.1 such that each process can be involved in at most one connection at a time. Processes p[i] and q[j] can be specified partially as follows: process p[i : 0..x-1] const y inp m : integer var conp : boolean, {init. false} cansnd : 0..m, peer : 0..y-1 begin timeout ~conp ^ (for all j: 0<=j statement [] ... end process q[j : 0..y-1] const x var conq : boolean, {init. false} peer : 0..x-1 par i : 0..x-1 begin ... end Complete the specifications of processes p[i : 0..x-1] and q[j : 0..y-1]. -------------------------------------------------------------------------------