CS6/73201 "Advanced Operating Systems" HOMEWORK #1 Due in class 10/2/2006 The numbers in parenthesis refer to "Introduction to Distributed Algorithms" (IDA) 1. consider the following program: process P process Q var var sent=0; rcvd=0; *[ *[ true --> message in channel from Q --> send message(s) to Q, receive message(r) from Q, s:=s+1 rcvd:=r ] a) Assume that it is coded on a real distributed architecture where the latency of message transmission between processes of P and Q is high (messages take very long to propagate). What computations would reflect this behavior. Give examples. Explain. b) Assume that the channel is fast but process Q is significantly slower than P. What computation would reflect this behavior? Give examples. Explain. c) Assume that process P, Q have about the same speed in the target architecture, however, P seldom has any messages to send to Q. What computation would be appropriate for this behavior? Give examples. Explain. 2. Assume that a distributed program is written in a program-counter based notation. That is, it has a sequence of statements of the form assign initial values to variables; statement1; statement2; statement3; statement4; ... Assuming that the atomicity of the program is the statement construct an equivalent guarded-command based program. In this the equivalence means the program generates the same set of computations. Assume that you have a guarded-command based program var variable list and initialization; *[ guard1--> statement1; [] guard2--> statement2; ... ] Is it possible to construct an equivalent program-counter based program? If yes, provide it. If not, explain why not. 3. Let a message-passing program have the following form: *[ local variable-predicate1 --> statementA1; statementB1; local variable-predicate2 --> statementA2; statementB2; receive message from another process --> statementR1; statementR2; ... ] That is there are two statements for guarded command. A statement is either sending a message or local computation. The atomicity for the program is a statement (not a guarded command). The execution semantics is interleaving. Prove that this program is equivalent to a program where every guarded command is executed atomically. Your answer should start as follows: Let us consider an arbitrary computation C1 of the above program. And it should end as follows. Therefore, for the computation C1, there always exists an equivalent computation C2 where the guarded commands are executed atomically. 4. Convert Tarry's traversal algorithm (Figure 6.13 in IDA) into guarded command notation, discuss why your guarded-command based program is equivalent to the algorithm in Figure 6.13. 5. Assume the following modification for the ring algorithm (Figure 6.2 in IDA) proc initiator const Next, Prev (* next and previous neighbor *) var boolean started=false, gotone=false *[ not started --> started:=true send to Next send to Prev [] receive from Next or Prev --> if gotone then decide else gotone:=true ] proc non-initiator const Next, Prev *[ receive from Prev --> send to Next [] receive from Next --> send to Prev ] a) formally prove or disprove that this is a wave algorithm b) for a particular ring size of N processes count the number of non-equivalent computations c) compute the time and message complexity of the algorithm 6. Consider the following modification of the ring algorithm proc initiator const Next, Prev (* next and previous neighbor *) var boolean started=false, *[ not started --> started:=true send to Next send to Prev ] proc all processes (including initiator) const Next, Prev *[ receive from Prev --> send to Next [] receive from Next --> send to Prev ] Does this algorithm have computations that are not weakly fair? If your answer is negative, prove it; if positive: show a weakly unfair computation. Do not worry about the lack of "decide" event at the initiator: it is made to simplify the code, the answer does not depend on it. 7. Will the tree algorithm (Figure 6.3 IDA) work on non-tree networks? That is, there are no modifications to the algorithm but the topology of the network is not a tree. Explain your answer. For the following topology: a b \ / c / \ d e list a pair of computations that are not equivalent and explain why they are not equivalent. 8. Assuming that "a" is the initiator, list all possible spanning trees that can be formed for the following topology: a----b |\ | | \ | | \ | | \| c----d Show which ones can be produced by: a) Tarry's algorithm b) Classical algorithm 9. Auerbach's algorithm is a modification of the classical depth-first traversal algorithm. The major change is that two new types of messages are introduced: and and the update rules for "used" array are modified. As a consequence of that it becomes necessary to explicitly require that only the initiator decides (notice that in Tarry's and Classical traversal algorithm it is done implicitly -- the only process that can possibly decide is the initiator). Explain why it is necessary and give an example where the Auerbach's algorithm _without_ this particular modification fails. 10.In Auerbach's algorithm. When a process P receives message it first sends message to every neighbor, waits for from every neighbor and then proceeds to forward . Would the algorithm be correct if a process does not wait for s to come back but forwards immediately after messages are sent? If yes, explain why; if no, explain why and provide a counter-example. 11.If each process uses a different value "d" (increment) in Lamport's logical clocks, do the clocks still preserve the causality relationship? That is, for two events A and B: if A -> B then C(A) < C(B) Explain your answer. 12.Consider the system of three processes (A,B,C) and the following computation: [B sends message M1 to C], [B sends M2 to A], [A receives M2], [A sends M3 to B], [A sends M4 to C], [C receives M4], [C receives M1], [C sends M5 to B], [B receives M5], [B receives M3] Apply SES causal message delivery algorithm. Draw a timing diagram of message receipts and deliveries according to SES. 13. Notice that the size of the matrix clock is quadratic with respect to the system size. Propose a technique similar to that of Singhal-Kshemkalyani to decrease the information transmitted and stored if the clocks do not change frequently.