CSCI1600: Embedded and Real Time Software Lecture 10: Modeling IV: Compositions of State Machines Steven Reiss, Fall 2015
Modeling Tasks We can model individual tasks using FSMs Extended FSMs, Timed automata, … Hybrid automata to reflect state of outside world This is sufficient for coding We need to model the overall application We need this to prove properties of the system We need this to understand overall system behavior What was in chapter 5
Statecharts We saw this last week Lets look at it in more detail Lets be able to understand it formally Map to a single FSM
Example : Concurrent Machines
Example: concurrency
Example: Concurrency
Example : communicating tasks
Example: hierarchical
Example: Hierarchical
Example
Tic-Tac-Toe
Issues Handling concurrency The FSM is in multiple states What does this mean formally (single FSA) What does this mean in a statechart What do you do with an input How is this implemented What if the results are contradictory (set x = 1, set x = 0) What does this mean for your implementation
Mapping to Code Direct sequential coding Determine state from various conditions Act accordingly Allows common operations for multiple states Explicit state variable switch (state) { … } Table-driven Approximate the state machine
Homework Read 6.1, 6.2, 6.4