Winter, 1999

CSE403 Homework#2 Due, Friday January 29, in class

Five (5) Questions

1. Let S be a function that is executed every p units of time (S is a periodic function with period p.) If S fails to complete within p units of time, a fault handler F is called; F recovers from the timing fault and reenters S where it last left off.

Draw a statechart showing the behavior and interactions between S and F.

2. Extension of the Railway Crossing Gate Example:

A gate, a pair of lights, and a computer controller are located at the intersection of a road and a railway track. The gate operates according to the fsm of the class handout. The controller assures that the gate is closed whenever a train is in the intersection area, and also controls the lights. If there are no trains in the area, the lights are green. When a first train enters the area, the lights turn to flashing red, and remain flashing until the last train leaves and the gate has completely opened; when the last train leaves the area, the gate is opened.

Give a statechart description of the system, containing these three components - gates, lights, and controller - with at least three corresponding parallel superstates.

3. A VCR can operate in three different modes:

i) Play: Commands or buttons are available to play, pause or stop, rewind, or eject a tape.

ii) Program: A user can set the machine to record the TV signal on tape from a given channel, starting at a particular time, and for a given duration.

iii) Record: The TV signal from a given channel can be recorded on tape, either manually in real-time or automatically as specified by a program ( ii) above).

Draw a statechart for the VCR. Your statechart should have at least three levels of structure, and use "interrupts" to describe mode changes.

4. Consider the Petri net in Figure 5.21, page 179 of the text.

(a) Exhibit a sequence of firings that illustrate how transitions t2 and t4 can starve.

(b) Give a sequence of firings that result in a marking from which t2 and t4 can never become enabled again.

5. Let two activities or processes A1 and A2 share a CPU and memory. There are two blocks of memory. A1 repeatedly executes the sequence:

Get CPU; Get 1 block of memory; Perform action A11; Get 2nd block of memory; Perform action A12; Release CPU and memory.

A2 repeatedly executes:

Get CPU; Get 1 block of memory; Perform action A21;

Release CPU and Memory.

Draw a Petri net that models this system. Show an initial marking with all of the resources available, and both activities ready to start their cycles.