CSE403 OPEN BOOK TEST Fri. Feb. 28, 1997 10:30-11:20

Five (5) Questions, Equally Weighted.

Write your name at the top of each page. Write your answers in the space provided. Use the back of the same page if necessary.

__________________________________________________________________

1. Consider the Petri net in Figure 5.23 on page 181 in the text (producer-consumer).

(a) Describe the marking of the net after each transition in the firing sequence: <produce, write, produce, read, consume>.

A marking can be described by listing the places containing tokens; for example, the initial marking in the net is (c1, 0, p1).

(b) Give the first five (5) transitions of another firing sequence, starting from the same initial state, that differs from the transitions of (a). Describe the marking after each transition.

 

2. Let Update and Read be two actions that are performed by several processes in parallel. Each action is bounded by start and end events; for example, ­Update is the start event for the Update action. Update actions must be mutually exclusive with respect to each other and with respect to Read actions. Express these constraints in real time logic (RTL).

 

3. Add a Reverse operation to the algebraic specification for strings, StringSpec (pp. 220-221 text, used in Homework #2). Reverse takes a string as argument and returns the string in reverse order. For example, reverse models an operation that would input a string "a b c" and return the string

" c b a".

 

4. Following is a program segment that computes the result of raising a positive integer z to an integer power y.

{ z and y are positive integers.}

x := 1; j := 1;

while y ³ j do

j := j + 1; x := x * z;

end loop;

{ x = z y }

The invariant P for the loop is { (x = z j-1) Ù (y ³ j-1) }. Assume that this has been proven.

(a) What assertion is true when exiting the loop.

(b) Show how your answer from (a) implies the truth of the final assertion.

(c) Using the axiom of assignment and the proof rules, show that the invariant P holds before entering the while statement, assuming the truth of the initial program assertion.

 

5. Recall the program segment from question 5 of Homework #3:

x := a; if x < 1 then x := 1;

while x < b do x := x + 1; end loop;

where a and b are integers.

(a) Give a minimal set of test cases for the program that provide statement coverage.

(b) Draw the control flow graph (CFG) for the program.

(c) Give a minimal set of test cases for the program that provide edge coverage with respect to the CFG.