Presentation is loading. Please wait.

Presentation is loading. Please wait.

Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.

Similar presentations


Presentation on theme: "Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University."— Presentation transcript:

1 Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University of California at Berkeley

2 Type System, March 12, 2002 - 2 Component Interfacing Two levels of interface: –data types and –dynamic interaction: communication & execution Dynamic behavior defined by models of computation (MoC)

3 Type System, March 12, 2002 - 3 Capturing Dynamic Behavior Dynamic behavior in each MoC can be described formally, using type systems Success of type systems: –Safety through type checking –Polymorphism supports reuse (flexible components) –Type conversion –Program optimization –Interface documentation, clarification –Run-time reflection of component interfaces

4 Type System, March 12, 2002 - 4 Data Types in Ptolemy II Lattice-based infrastructure Support polymorphism, type conversion, and structured types General String Scalar Boolean Complex Double Long Int Unknown

5 Type System, March 12, 2002 - 5 Behavioral Type Data types only specify static aspects of interface Proposal: –Capture the dynamic interaction of components in types –Obtain benefits analogous to data typing –Call the result behavioral types

6 Type System, March 12, 2002 - 6 Interaction Semantics Flow of control issues –in Ptolemy II, these are defined by a Director class Communication between components –in Ptolemy II, this is defined by a Receiver class Actor interface for execution: fire Receiver interface for communication: put, get, hasToken

7 Type System, March 12, 2002 - 7 Receiver Object Model

8 Type System, March 12, 2002 - 8 Models of Computation Define the interaction semantics Implemented in Ptolemy II by a domain –Receiver + Director Examples: –Communicating Sequential Processes (CSP): rendezvous-style communication –Process Networks (PN): asynchronous communication –Synchronous Data Flow (SDF): stream-based communication, statically scheduled –Discrete Event (DE): event-based communication –Synchronous/Reactive (SR): synchronous, fixed point semantics

9 Type System, March 12, 2002 - 9 Formal Interaction Semantics: Use Interface Automata Based on interface automata –Proposed by de Alfaro and Henzinger –Concise composition (vs. standard automata) –Alternating simulation provides contravariance Compatibility checking –Done by automata composition –Captures the notion “components can work together” Alternating simulation (from Q to P) –All input steps of P can be simulated by Q, and –All output steps of Q can be simulated by P. –Provides the ordering we need for subtyping & polymorphism Key theorem about compatibility and alternating simulation

10 Type System, March 12, 2002 - 10 Example: Synchronous Dataflow (SDF) Consumer Actor Type Definition fRReturn from fire gget hThasToken ffire tToken hTTReturn True from hasToken hTFReturn False from hasToken Inputs: Outputs: Such actors are passive, and assume that input is available when they fire. execution interface communication interface

11 Type System, March 12, 2002 - 11 Type Definition – Synchronous Dataflow (SDF) Domain receiver interface director interface

12 Type System, March 12, 2002 - 12 Type Checking – Compose SDF Consumer Actor with SDF Domain Compose SDF Domain SDF Consumer Actor

13 Type System, March 12, 2002 - 13 Type Definition – SDF Consumer Actor in SDF Domain 1. receives token from producer interface to producer actor 2. accept token 3. internal action: fire consumer 4. internal action: call get() 5. internal action: get token 6. internal action: return from fire

14 Type System, March 12, 2002 - 14 Type Definition – Discrete Event (DE) Domain This domain may fire actors without first providing inputs

15 Type System, March 12, 2002 - 15 Recall Component Behavior SDF Consumer Actor 1.is fired 2.calls get() 3.gets a token 4.returns

16 Type System, March 12, 2002 - 16 Type Checking – Compose SDF Consumer Actor with DE Domain Empty automaton indicates incompatibility Composition type has no behaviors Compose DE Domain SDF Consumer Actor

17 Type System, March 12, 2002 - 17 Subtyping Relation Alternating Simulation: SDF  DE SDF Domain DE Domain 

18 Type System, March 12, 2002 - 18 System-Level Type Lattice – Defined by Alternating Simulation Subtyping relation Shown here for a few Ptolemy II domains If an actor is compatible with a certain type, it is also compatible with the subtypes discrete events synchronous dataflow unknown process networks communicating sequential processes domain polymorphic

19 Type System, March 12, 2002 - 19 Type Definition – Domain Polymorphic Consumer Actor 1. is fired 2. calls hasToken() 3. true 3. false 4. return 4. call get() 5. get token 6. return This actor checks for token availability before attempting to get the token.

20 Type System, March 12, 2002 - 20 Domain Polymorphic Actor Composes with the DE Domain Compose DE Domain Poly Actor

21 Type System, March 12, 2002 - 21 Domain Polymorphic Actor Also Composes with the SDF Domain Compose Poly Actor SDF Domain

22 Type System, March 12, 2002 - 22 Conclusion Data types –Lattice-based infrastructure –Support polymorphism, type conversion, and structured types Behavioral types –Formally captures the structure of MoCs –Describe interaction types and component behavior using interface automata –Perform type checking through automata composition –Subtyping order is given by the alternating simulation relation, supporting polymorphism


Download ppt "Type System, March 12, 2002 - 1 Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University."

Similar presentations


Ads by Google