The State Machine Simulation Language

The State Machine Simulation Language - CS1102: The State...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1102: The State Machine Simulation Language Kathi Fisler, WPI September 28, 2004 1 Introduction: What’s a State Machine Simulator? 1.1 Example 1: Traffic Lights Imagine that an engineering firm is designing new software for controlling the sequence of lights displayed by a traffic light. Given that a malfunctioning light could result in accidents, they want to monitor whether the new design is producing an expected (and acceptable) sequence of light colors. Suppose they sampled the current light color at short, regular intervals. A sequence that cycled through the colors in order, such as red red green green yellow red red green yellow . .. matches the expected behavior of a traffic light. If, however, the monitor detected an out-of-order sequence, such as red yellow red yellow yellow red . .. then the monitor should report that the design contains an error. Our goal in this lecture is to create programs for defining and running monitors. First, how might we define a monitor (forget how to run it for the moment)? Here’s a common graphical notation (known as a state machine —you may have heard the equivalent term finite automaton ): red green yellow green yellow red is-yellow is-green is-red What does this notation mean? The circles are known as states : they name the different valid configurations that a monitor could be in. For the traffic light, the monitor can be seeing one of the three light colors (red, yellow, or green); the states indicate the color of the light at the last sampling. The arrows are known as transitions (or sometimes edges ): they show relationships between valid configura- tions. Notice that each arrow has a label on it. That label is known as a guard . A transition indicates the conditions under which the monitor can change configurations. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
For example, the transition from is-red to is-green has a guard green . This indicates that if the monitor is in the is-red configuration and sees a green light on the next sampling, then the monitor enters the is-green configuration. Notice, however, that this is no transition leaving is-red with the guard yellow . That means that if the monitor is in the is-red configuration and the light sampling shows yellow, then the monitor should report an error (because something unexpected happened). The lack of a transition matching the current sample always indicates an error. The stubby arrow with nothing at its source marks the starting configuration . This example says that all traffic lights start displaying a red light. This example shows how we can use state machines to write down monitors. Given a monitor as a state machine, how do we run it to watch for errors? In addition to the monitor, we need a list of the data sampled at each time. Assume we had a way to remember the current configuration. We take the first sample off the list, change configurations by matching the sample against the guards, and repeat on the rest of the list. For example, assume we had the state
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/06/2008 for the course CS 1102 taught by Professor Fisler during the Fall '07 term at WPI.

Page1 / 6

The State Machine Simulation Language - CS1102: The State...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online