CMPSCI 521/621 HW6 Solutions Problem 1 (based on Xiang Zhao s solution). The node labels are an ordered pair that indicates the location of the program counter in the two different tasks. The first element in a pair corresponds to the location of the program counter in Task2 1 and the second element corresponds to the location of the program counter in Task 2. R(x,y) means a rendezvous between node x Task 1 and node y in Task 2. The notation b x means that a task is blocked at node x. 1
Problem 2 (based on Xiang Zhao s solution). Initially, there is one token at P0 and one token at P5. Note, there are 3 transitions out of P1 to represent the fact that Task 1 can synchronize with Task 2 in the following ways: statement 2 at Task 1 with statement 5 at Task 2 statement 2 at Task 1 with statement 6 at Task 2 statement 3 at Task 1 with statement 7 at Task 2 Also, pay attention to the transitions out of P2 and P3. They represent the fact that after Task 1 has synchronized with Task 2, Task 1 can either end (the downwards pointing transitions) or loop (the upwards pointing transitions). 2
Problem 3 INCA equations Task Flow Equations: x1 = 1 x7 = 1 x8 = 1 x13 = 1 x1 + x6 = x2 + x3 x2 = x4 x3 = x5 x4 + x5 = x7 + x6 x8 = x9 + x10 x9 = x11 x10 = x12 x11 + x12 = x13 Inter-Task Flow Equations x4 = x9 + x10 + x11 x5 = x12 Non-Negative Flow Equations j : x j 0 Property equation x4 = x4 The complement of the property is x4 x5, which is equivalent to x4 > x5 x4 < x5. Thus, any solution to x4 > x5 combined with the Task, Inter-Task and Non-Negative Flow equations will correspond to a property violation. Similarly, any solution to x4 < x5 combined with the Task, Inter-Task and Non-Negative Flow equations will correspond to a property violation. A solution that satisfies x4 > x5 combined with the Task, Inter-Task and Non-Negative Flow equations 3
is: x1 = x6 = x7 = x8 = x9 = x11 = x13 = 1 x3 = x5 = x10 = x12 = 0 x2 = x4 = 2 A counter example path that corresponds to this solution is Task 1: start, 1, 2, 4, 1, 2, 4, end. Task 2: start, 5, 6, 8, end. The rendezvous between b and b happens 1 times and the rendezvous between a and a happens 0 times, therefore the property is violated. Problem 4 (based on Xiang Zhao s solution). The CFG and the constraint are shown above. The CFG is annotated with the IN and OUT sets that are computed after state propagation has reached a fixed point. Each element in the IN/OUT sets is a tuple 4
of the form < x, y >, where x represents a state from the property automaton and y represents a state from the constraint automaton shown above. The tuples that are crossed out represent situations when the constraint automaton transitions to a violation state. This situations correspond to infeasible paths (e.g., on the same execution, the truth branch at node 3 is taken and then later the false one is taken, or vice versa). To determine if the property holds, we look at the OUT set of the final node and consider only the tuples in which the constraint automaton is in an accepting state. (In this example, the constraint automaton is in an accepting state (u, f, t) in all tuples). For these tuples, we then check if the property automaton is in an accepting state or not. If it is, the property holds; if there is at least one tuple in which the constraint is in an accepting state and the property is in a non-accepting state, then the property is violated. In this example, the property is satisfied since in all the tuples in the OUT set of the final node, the property and the constraint automata are in an accepting state. Problem 5 Reachability Graph (based on Brandon McPhail s solution and his (and his wife s) imagination.) Happy Holidays!!! 1,5a' r(2a,5a') 3b,5a' 2,6a' 4,5 2,7b' b4,5a' Second iteration 1,5 4,6a' 4,7b' end,5 b-end,5a' b1,5a' 2a,5 1,6a' 1,7b' 3b,5 end,6a' end,7b' r(b2a,5a') b3b,5a' a4,5 2a,7b' r(2a,6a') r(3b,7b') 3b,6a' r(b2,7b') b2,6a' b4,5 bb4,5a' a1,5 a4,7b' a-end, 5 r(a4,6a') 4,6 2,8 3,8 4,7 r(b4,7b') b-end, b4,6a' b1,5' b4,6a' 5 bb1,5a' bb-end, 5a' a1,7b' a-end, 7b' a-end, 7b' r(a-end, 6a') 1,6 end,6 2,end 4,8 3,end end,7 1,7 b1,6a' r(b-end, 7b') b-end, 6a' b1,6a' 1,8 end,8 4,end end,end 1,end To reduce some visual clutter, the reachability graph starts at the point where Task 1 is at statement 1 and Task 2 is at statement 5 a (nothing really interesting happens before Task 1 and Task 2 reach that point). 5
Notation: Dotted transitions and nodes indicate the situation where the Task 1 is about to start a second iteration of the loop from statement 4 to statement 1. The reachability graph is cut at that point since the problem specified that the loop can be taken at most one time. If a message is sent by one task but not immediately received by the other, a letter is used as a prefix before the task number to indicate that a receipt is pending. For example, b4, 5a means that task 1 is in statement 4, it has sent message b earlier but b has not been received by task 2 yet, and task 2 is at statement 5 waiting to receive a. The states with a doubled boundary indicate where deadlocks might occur. Petri Net (based on Stephan Moczygemba s solution) 6