Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logical Clocks (addendum). Logical Clocks In the class of Feb 3 the question was asked about having different numbers for different events.

Similar presentations


Presentation on theme: "Logical Clocks (addendum). Logical Clocks In the class of Feb 3 the question was asked about having different numbers for different events."— Presentation transcript:

1 Logical Clocks (addendum)

2 Logical Clocks In the class of Feb 3 the question was asked about having different numbers for different events.

3 Example 1 Assume that P3 has a loop that is executed n times. At the termination of the loop a message is sent to P1. The value of n is arbitrary. A part of P3’s code could look something like this: 3.1: i = 0; 3.2: while (i < n) 3.3: i = i+1; 3.4: send (i,P2); Assume that n = 2; The timing diagram would look something like what appears on the next page.

4 Example 1 a b P1P2 P3 c d e f g h i j p j is the event that statement 3.1 executes; k is the event that 3.2 executes; l is the event that 3.3 executes; m is the event that 3.2 executes; n is the event that 3.3 executes; o is the event that 3.2 executes; p is the event that statement 3.4 executes k l m 1 1 2 3 4 3 8 9 10 l n 2 3 4 5 7 6 o

5 Example 1 a b P1P2 P3 c d e f g h i j Assume n is 1 instead of 2. Event j is associated with statement 3.1; Event k is associated with statement 3.2; Event l is associated with Statement 3.3; Event m is associated with statement 3.2; Event n is associated with statement 3.4 k l m 1 1 2 3 4 3 6 7 8 l n 2 3 4 5

6 Example 2 In the previous examples we had statements like “recv(x, P3)” – basically it was made explicit where a message was to be received from. However, this doesn’t have to be the case. Essentially we can have “recv(x,?)” where the process is waiting for any process. Assume that P2 has a code segment that looks like the following: 3.1: while(;;) { 3.2: recv(x,?); 3.3 Process message} P1 and P3 are processes that send messages to P2.

7 Example a b P1P2 P3 c d e f g i j m n o Event e represents the execution of 3.1; Event f represents the execution of 3.2; event g represents the execution of event 3.3; event h represents the execution of 3.1; event i represents the execution of 3.2; event j represents the execution of 3.3; event k represents the execution of 3.1; Event l represents the execution of 3.2 1 1 12 3 503 4 4 51 52 51 h5 k l 53 54 Lots of processing; Assume that k is 50

8 Example P1 may be on a much faster machine then P3 and so both its messages may arrive at P2 before P3’s messages

9 Example a b P1P2 P3 c d e f g i j j k l Event e represents the execution of 3.1; Event f represents the execution of 3.2; event g represents the execution of event 3.3; event h represents the execution of 3.1; event i represents the execution of 3.2; event j represents the execution of 3.3; event k represents the execution of 3.1; Event l represents the execution of 3.2 1 1 12 3 503 4 4 6 7 51 h k l 8 5


Download ppt "Logical Clocks (addendum). Logical Clocks In the class of Feb 3 the question was asked about having different numbers for different events."

Similar presentations


Ads by Google