CIS 540 Principles of Embedded Computation Spring 2016 Instructor: Rajeev Alur

Slides:



Advertisements
Similar presentations
My Internet Safety Guide I have used scratch to program a guide to internet safety using QR codes.
Advertisements

CommUnity, Tiles and Connectors joint work with Roberto Bruni José Luiz Fiadeiro Antónia Lopes Ugo Montanari Ivan Lanese Dipartimento di Informatica Università.
Programming in Occam-pi: A Tutorial By: Zain-ul-Abdin
Finite State Machines (FSMs)
Models of Concurrency Manna, Pnueli.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Compiling Communicating Processes into Delay-Insensitive VLSI Circuits Alain J. Martin Department of Computer Science California Institute of Technology.
Lecture 12 Latches Section Schedule 3/10MondayLatches (1) /12WednesdayFlip-flops5.4 3/13ThursdayFlip-flops, D-latch 3/17MondaySpring.
Lecture 12 Latches Section , Block Diagram of Sequential Circuit gates New output is dependent on the inputs and the preceding values.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Interface Automata 29-September Modeling Temporal Behavior of Component Component behaves with Environment Traditional (pessimistic) approach –
CS 584. A Parallel Programming Model We need abstractions to make it simple. The programming model needs to fit our parallel machine model. Abstractions.
1 Digital Logic
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
Mapping Techniques for Load Balancing
© Richard Welke 2002 CIS 4120 Fa13: Define/Innovate BP’s Richard Welke Director, CEPRIN Professor, CIS Robinson College of Business Georgia State University.
Sequential Circuits Chapter 4 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Some Useful Circuits Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Instructor: Rajeev Alur
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
SOFTWARE DESIGN.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
The Complexity of Distributed Algorithms. Common measures Space complexity How much space is needed per process to run an algorithm? (measured in terms.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Qusay H. Mahmoud CIS* CIS* Service-Oriented Computing Qusay H. Mahmoud, Ph.D.
Hwajung Lee. Well, you need to capture the notions of atomicity, non-determinism, fairness etc. These concepts are not built into languages like JAVA,
Hwajung Lee. Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity, non-determinism,
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Lecture 4 Introduction to Promela. Promela and Spin Promela - process meta language G. Holzmann, Bell Labs (Lucent) C-like language + concurrency dyamic.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
Chapter 8 Asynchronous System Model by Mikhail Nesterenko “Distributed Algorithms” by Nancy A. Lynch.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CS151 Introduction to Digital Design Chapter 5: Sequential Circuits 5-1 : Sequential Circuit Definition 5-2: Latches 1Created by: Ms.Amany AlSaleh.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Design Components are Code Components
CPE555A: Real-Time Embedded Systems
Timing Model Start Simulation Delay Update Signals Execute Processes
Parallel and Distributed Simulation Techniques
CSCI1600: Embedded and Real Time Software
Boolean Algebra and Digital Logic
Autonomous Cyber-Physical Systems: Synchronous Components: II
Chapter 20 Object-Oriented Analysis and Design
Spring CS 599. Instructor: Jyo Deshmukh
Analysis models and design models
Channels.
Design Components are Code Components
Concurrency: Mutual Exclusion and Process Synchronization
CS561 Computer Architecture Hye Yeon Kim
Presentation transcript:

CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur

Asynchronous Models  Recap: In a synchronous model, all components execute in a sequence of (logical) rounds in lock-step  Asynchronous: Speeds at which different components execute are independent (or unknown)  Processes in a distributed system  Threads in a typical operating system such as Linux/Windows  Key design challenge: how to achieve coordination? CIS 540 Spring 2016; Lecture Feb 17

Example: Asynchronous Buffer  Input channel: in of type Boolean bool in bool out {0,1,null} x := null A i : x := in  Output channel: out of type Boolean  State variable: x; can be empty/null, or hold 0/1 value  Initialization of state variables: assignment x:=null  Input task A i for processing of inputs: code: x:= in A o : x != null  { out:=x; x:=null}  Output task A o for producing outputs: Guard: x != null; code: out:=x; x:=null CIS 540 Spring 2016; Lecture Feb 17

Example: Asynchronous Buffer bool in bool out {0,1,null} x := null A i : x := in A o : x != null  { out:=x; x:=null}  Execution Model: In one step, only a single task is executed  Processing of inputs (by input tasks) is decoupled from production of outputs (by output tasks)  A task can be executed if it is enabled, i.e., its guard condition holds  If multiple tasks enabled, one of them is executed  Sample Execution: null in?0 0 out!0 null in?1 1 in?0 0 out!0 null CIS 540 Spring 2016; Lecture Feb 17

Example: Asynchronous Increments nat x:=0; y:=0 A x : x := x+1 A y : y :=y+1  Internal task: Does not involve input or output channels  Can have guard condition and update code  Execution of internal task: Internal action  In each step, execute, either task A x or task A y  Sample Execution: (0,0)  (1,0)  (1,1)  (1,2)  (1,3)  …  (1,105)  (2, 105) …  For every m, n, state (x=m, y=n) is reachable  Interleaving model of concurrency CIS 540 Spring 2016; Lecture Feb 17

Asynchronous Merge Sequence of messages on output channel is an arbitrary merge of sequences of values on the two input channels msg in1 msg out queue(msg) x1 := null; x2 := null A1: ~Full(x1)  Enqueue(in1, x1) msg in2 A2: ~Full(x2)  Enqueue(in2, x2) B1: ~Empty(x1)  out := Dequeue(x1) B2: ~Empty(x2)  out := Dequeue(x2) CIS 540 Spring 2016; Lecture Feb 17

Asynchronous Merge At every step exactly one of the four tasks executes, provided its guard condition holds msg in1 msg out queue(msg) x1 := null; x2 := null A1: ~Full(x1)  Enqueue(in1, x1) msg in2 A2: ~Full(x2)  Enqueue(in2, x2) B1: ~Empty(x1)  out := Dequeue(x1) B2: ~Empty(x2)  out := Dequeue(x2) Sample Execution: ([],[]) – in1?5 -> ([5], []) – in2?0 -> ([5],[0]) – out!0 -> ([5],[]) – in1?6 -> ([5,6],[]) – in2?3 -> ([5,6],[3]) – out!5 -> ([6],[3]) … CIS 540 Spring 2016; Lecture Feb 17

What does this process do? int in1 int out int+null x1 := null; x2 := null A1: x1 = null  x1 := in1 int in2 A2: x2 = null  x2 := in2 B: (x1 != null) & (x2 != null)  { out := x1 + x2; x1 := null; x2 := null } CIS 540 Spring 2016; Lecture Feb 17

Definition: Asynchronous Process P  Set I of (typed) input channels  Defines the set of inputs of the form x?v, where x is an input channel and v is a value  Set O of (typed) output channels  Defines the set of outputs of the form y!v, where y is an output channel and v is a value  Set S of (typed) state variables  Defines the set of states Q S  Initialization Init  Defines the set [Init] of initial states CIS 540 Spring 2016; Lecture Feb 17

Definition (contd): Asynchronous Process P  Set of input tasks; each such task is associated with an input channel x  Guard condition over state variables S  Update code from read-set S U {x} to write-set S  Defines a set of input actions of the form s – x?v -> t  Set of output tasks; each task is associated with an output channel y  Guard condition over state variables S  Update code from read-set S to write-set S U {y}  Defines a set of output actions of the form s – y!v -> t  Set of internal tasks  Guard condition over state variables S  Update code from read-set S to write-set S  Defines a set of internal actions of the form s –  -> t CIS 540 Spring 2016; Lecture Feb 17

Asynchronous Gates bool inbool out  Why design asynchronous circuits?  Input can be changed even before the effect propagates through the entire circuit  Can be faster than synchronous circuits, but design more complex  Modeling a NOT gate  When input changes, gate enters unstable state till it gets a chance to update output value  If input changes again in unstable state, then this causes a hazard where behavior is unpredictable CIS 540 Spring 2016; Lecture Feb 17

Executing an ESM Each mode-switch corresponds to a task Example input task: (mode = stable)  if (in=x) then mode := unstable Example output task: (mode = stable)  out := x Example internal task: (mode = unstable)  { x:=~x; mode := stable } CIS 540 Spring 2016; Lecture Feb 17

Asynchronous NOT Gate as an ESM Sample Execution: (stable,0) – out!0 -> (stable,0) – in?0 -> (unstable,0) –  -> (stable, 1) – out!1 -> (stable,1) – in?1 -> (unstable,1) –out!1 -> (unstable,1) – in?0 -> (hazard,1) – out!0 -> (hazard,1) – out!1 -> (hazard,1) … How to ensure that the gate does not enter hazard state? When the input toggles, wait to observe a change in value of output! CIS 540 Spring 2016; Lecture Feb 17

Block Diagrams  Visually the same as the synchronous case  Execution semantics different ! CIS 540 Spring 2016; Lecture Feb 17

DoubleBuffer  Instantiation: Create two instances of Buffer  Output of Buffer1 = Input of Buffer2 = Variable temp  Parallel composition: Asynchronous concurrent execution of Buffer1 and Buffer2  Hide variable temp: Encapsulation (temp becomes local) bool in bool temp Buffer1 bool out Buffer2 ( Buffer[out -> temp] | Buffer[in -> temp] ) \ temp CIS 540 Spring 2016; Lecture Feb 17

Composing Buffer1 and Buffer2  Inputs, outputs, states, and initialization for composition obtained in the same manner as in synchronous case  What are the tasks of the composition?  Production of output on temp by Buffer1 synchronized with consumption of input on temp by Buffer2 bool in bool temp Buffer1 bool out Buffer2 {0,1,null} x1 := null {0,1,null} x2 := null A1 i : x1 := inA2 i : x2 := temp A1 o : (x1 != null)  { temp:=x1; x1:=null} A2 o : (x2 != null)  { out:=x2; x2:=null} CIS 540 Spring 2016; Lecture Feb 17

Compiled DoubleBuffer bool in bool out {0, 1, null} x1 := null; x2 := null A1 i : x1 := in A2 o : (x2 != null)  {out:=x2; x2:=null} B (A1 o + A2 i ): (x1 != null)  { local bool temp temp:=x1; x1:=null; x2:= temp } bool in bool temp Buffer1 bool out Buffer2 {0,1,null} x1 := null {0,1,null} x2 := null A1 i : x1 := inA2 i : x2 := temp A1 o : (x1 != null)  { temp:=x1; x1:=null} A2 o : (x2 != null)  { out:=x2; x2:=null} CIS 540 Spring 2016; Lecture Feb 17

Definition of Asynchronous Composition  Given asynchronous processes P1 and P2, how to define P1 | P2 ?  Note: In each step of execution, only one task is executed  Concepts such as await-dependencies, compatibility of interfaces, are not relevant  Sample case (see textbook for complete definition):  if y is an output channel of P1 and input channel of P2, and  A1 is an output task of P1 for y with code: Guard1  Update1  A2 is an input task of P2 for y with code: Guard2  Update2, then  Composition has an output task for y with code: (Guard1 & Guard2)  Update1 ; Update2 CIS 540 Spring 2016; Lecture Feb 17

Execution Model: Another View  A single step of execution  Execute an internal task of one of the processes  Process input on an external channel x: Execute an input task for x of every process to which x is an input  Execute an output task for an output y of some process, followed by an input task for y for every process to which y is an input  If multiple enabled choices, choose one non-deterministically  No constraint on relative execution speeds CIS 540 Spring 2016; Lecture Feb 17

Asynchronous Merge msg in1 msg out queue(msg) x1 := null; x2 := null A1: ~Full(x1)  Enqueue(in1, x1) msg in2 A2: ~Full(x2)  Enqueue(in2, x2) B1: ~Empty(x1)  out := Dequeue(x1) B2: ~Empty(x2)  out := Dequeue(x2) msg in1 msg in2 msg temp msg in3 msg out Merge Merge1Merge2 CIS 540 Spring 2016; Lecture Feb 17

Asynchronous Execution What can happen in a single step of this asynchronous model P?  P1 synchronizes with the environment to accept input on in  P2 synchronizes with the environment to send output on out  P1 performs some internal computation (one of its internal tasks)  P2 performs some internal computation (one of its internal tasks)  P1 produces output on channel x, followed by its consumption by P2  P2 produces output on channel y, followed by its consumption by P1 in x P1 out P2 y P CIS 540 Spring 2016; Lecture Feb 17