Embedded Systems 7. Models of computation for embedded systems

Similar documents
Embedded Systems 8. Identifying, modeling and documenting how data moves around an information system. Dataflow modeling examines

Embedded Systems 7 BF - ES - 1 -

Specifications Part 2

fakultät für informatik informatik 12 technische universität dortmund Data flow models Peter Marwedel TU Dortmund, Informatik /10/08

Dataflow Languages. Languages for Embedded Systems. Prof. Stephen A. Edwards. March Columbia University

SDL. Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund, Informatik 年 10 月 18 日. technische universität dortmund

Embedded Systems CS - ES

FSMs & message passing: SDL

Hardware Software Codesign

Overview of Dataflow Languages. Waheed Ahmad

Specifications and Modeling

EE249 Discussion Petri Nets: Properties, Analysis and Applications - T. Murata. Chang-Ching Wu 10/9/2007

Embedded Systems 7. Petri net plan coordination for robocup teams G. Kontes and M.G. Lagoudakis BF - ES BF - ES - 2 -

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

Fundamental Algorithms for System Modeling, Analysis, and Optimization

HW/SW Codesign. Exercise 2: Kahn Process Networks and Synchronous Data Flows

Petri Nets ee249 Fall 2000

Specifications and Modeling

Outline. Petri nets. Introduction Examples Properties Analysis techniques. 1 EE249Fall04

Imperative model of computation

From synchronous models to distributed, asynchronous architectures

Concurrent Models of Computation

Specifications Part 1

Petri Nets. Robert A. McGuigan, Department of Mathematics, Westfield State

fakultät für informatik informatik 12 technische universität dortmund Specifications Peter Marwedel TU Dortmund, Informatik /11/15

By: Chaitanya Settaluri Devendra Kalia

Comparison of models. Peter Marwedel Informatik 12, TU Dortmund, Germany 2010/11/07. technische universität dortmund

Petri Nets ~------~ R-ES-O---N-A-N-C-E-I--se-p-te-m--be-r Applications.

Discrete Event Models

EC-821 Advanced Embedded Systems (3+0)

EE382N.23: Embedded System Design and Modeling

Concurrent Models of Computation

Model checking pushdown systems

Concurrent Systems Modeling using Petri Nets Part II

PROF. TAJANA SIMUNIC ROSING. Final Exam. Problem Max. Points Points 1 25 T/F 2 10 Esterel 3 20 Petri net 4 20 SDF 5 20 EDF/RM 6 20 LS/power Total 115

Compositionality in Synchronous Data Flow: Modular Code Generation from Hierarchical SDF Graphs

Discrete Event Models

Models of computation

Imperative model of computation

Petri Nets. Petri Nets. Petri Net Example. Systems are specified as a directed bipartite graph. The two kinds of nodes in the graph:

Computational Models for Concurrent Streaming Applications

fakultät für informatik informatik 12 technische universität dortmund Modeling levels Peter Marwedel TU Dortmund, Informatik /11/07

Lecture 3: Intro to Concurrent Processing using Semaphores

Modelling, Analysis and Scheduling with Dataflow Models

An Algorithm to Compute a Basis of Petri Net Invariants

Process Management And Synchronization

Coverability Graph and Fairness

EE 382C Interconnection Networks

Finite State Verification. CSCE Lecture 14-02/25/2016

Concurrent Systems Modeling using Petri Nets Part II

Imperative model of computation

Computational Process Networks a model and framework for high-throughput signal processing

Actors and their composition. Jörn W. Janneck

Concept of a process

Petri Nets: Properties, Applications, and Variations. Matthew O'Brien University of Pittsburgh

Finite State Verification. CSCE Lecture 21-03/28/2017

Operating Systems 2010/2011

LabVIEW Based Embedded Design [First Report]

Main application of SDF: DSP hardware modeling

The Drinking Philosophers Problem-1

WEEK 5 - APPLICATION OF PETRI NETS. 4.4 Producers-consumers problem with priority

A Schedulability-Preserving Transformation Scheme from Boolean- Controlled Dataflow Networks to Petri Nets

Early design phases. Peter Marwedel TU Dortmund, Informatik /10/11. technische universität dortmund. fakultät für informatik informatik 12

Operating Systems 2006/2007

CSE237a Final Exam Winter Prof. Tajana Simunic Rosing. Problem Maximum points Points earned Total 100

Diagnostic Information for Control-Flow Analysis of Workflow Graphs (aka Free-Choice Workflow Nets)

Introduction to MARIA and High-Level Petri Nets

STATIC SCHEDULING FOR CYCLO STATIC DATA FLOW GRAPHS

Material from Recitation 1

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Concurrency. Chapter 5

Lecture 4: Synchronous Data Flow Graphs - HJ94 goal: Skiing down a mountain

Slides for Faculty Oxford University Press All rights reserved.

Interprocess Communication By: Kaushik Vaghani

APETRI net (PN) (cf. [1] [3]) is said to be live if it is possible

Distributed Algorithms 6.046J, Spring, Nancy Lynch

CS 242. Fundamentals. Reading: See last slide

CSE Traditional Operating Systems deal with typical system software designed to be:

Bounded Scheduling of Process Networks. Thomas M. Parks. B.S.E (Princeton University) in the

Timo Latvala. January 28, 2004

Modeling Hybrid Systems with Petri Nets

4/6/2011. Model Checking. Encoding test specifications. Model Checking. Encoding test specifications. Model Checking CS 4271

Distributed Deadlock Detection for. Distributed Process Networks

Applying Models of Computation to OpenCL Pipes for FPGA Computing. Nachiket Kapre + Hiren Patel

The SPIN Model Checker

A Deterministic Concurrent Language for Embedded Systems

Algorithmic Verification. Algorithmic Verification. Model checking. Algorithmic verification. The software crisis (and hardware as well)

Requirements on the Execution of Kahn Process Networks

Formal Support for QVT-Relations with Coloured Petri Nets

DIGITAL VS. ANALOG SIGNAL PROCESSING Digital signal processing (DSP) characterized by: OUTLINE APPLICATIONS OF DIGITAL SIGNAL PROCESSING

MODERN automated manufacturing systems require. An Extended Event Graph With Negative Places and Tokens for Time Window Constraints

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Resource Allocation - Dining Philosophers. Dining Philosophers - Properties. OK? EATING[(i%N)+1]) Impossibility Result for Symmetric Algorithm

Building Synchronous DataFlow graphs with UML & MARTE/CCSL

A Brief Introduction to Coloured Petri Nets

Discrete, Continuous, and Hybrid Petri Nets

Message Passing Part I

Department of Computer applications. [Part I: Medium Answer Type Questions]

Transcription:

Embedded Systems 7 - - Models of computation for embedded systems Communication/ local computations Communicating finite state machines Data flow model Computational graphs Von Neumann model Discrete event (DE) model Shared memory StateCharts, StateFlow C, C++, Java VHDL, Simulink Message passing Synchronous Asynchronous SDL, MSCs Kahn process networks, SDF Petri nets C, C++, Java with libraries CSP, ADA Only experimental systems, e.g. distributed DE in Ptolemy - 2 -

Place/transition nets Def.: (P, T, F, K, W, M 0 ) is called a place/transition net (P/T net) iff. N=(P,T,F) is a net with places p P and transitions t T 2. K: P (N 0 {ω}) \{0} denotes the capacity of places (ω symbolizes infinite capacity) 3. W: F (N 0 \{0}) denotes the weight of graph edges 4. M 0 : P N 0 {ω} represents the initial marking of places W (Segment of some net) M 0 defaults: K = ω W = In the following: assume initial marking is finite, capacity ω. - 3 - Unbounded Petri net p 2 t t 2 p 3 2 p 2 2-4 - 2

Invariants & boundedness A net is covered by place invariants iff every place is contained in some invariant. Theorem 4: a) If R is a place invariant and p R, then p is bounded. b) If a net is covered by place invariants then it is bounded. - 5 - Deadlock A dead marking (deadlock) is a marking where no transition can fire. A Petri net is deadlock-free if no dead marking is reachable. - 6-3

Structural properties: deadlock-traps A place set S is a (static) deadlock if every transition that adds token from S also removes token from S. A place set S is a trap if every transition that removes token from S also adds token to S. - 7 - Empty structural deadlocks and marked traps Empty structural deadlocks are never re-marked; Marked traps are never emptied. - 8-4

Sufficiently marked places A place is called sufficiently marked if there are enough token for one of the outgoing transitions: Define W - (p)= min { W(p,t) (p,t) F } if there exists a (p,t) F and 0 otherwise Place p is sufficiently marked in marking M, if M(p) W - (p) A set of places is sufficiently marked if it contains a sufficiently marked place. 2 2-9 - Deadlock-Trap Property A P/T has the deadlock-trap property, if every (static) deadlock contains a trap that is sufficiently marked in M 0. - 0-5

Deadlock-Trap Property Theorem 5: Every homogeneous P/T net with non-blocking weights that has the deadlock-trap property is deadlock-free. Homogeneous: For each place, all outgoing edges have the same weight. Non-blocking weights: W + (p) W - (p) W - (p)= min { W(p,t) (p,t) F } if there exists a (p,t) F and 0 otherwise W + (p)= min { W(t,p) (t,p) F } if there exists a (t,p) F and 0 otherwise - - Fairness Dining philosophers problem n> philosophers sitting at a round table; n forks, n plates with spaghetti; philosophers either thinking or eating spaghetti (using left and right fork). 2 forks needed! - 2-6

e 5 e s 5 f s f 5 f 2 s 4 s 2 f4 f 3 e 4 e 2 s 3 e 3-3 - e 5 e s 5 f s f 5 f 2 s 4 s 2 f4 f 3 e 4 e 2 s 3 e 3-4 - 7

Fairness Let N be a Petri net and w an execution of N. w is impartial with respect to a set of transitions T iff every transition in T occurs infinitely often in w. w is just with respect to a set of transitions T iff every transition in T that is enabled in all except finitely many markings occurs infinitely often in w. w is fair with respect to a set of transitions T iff every transition in T that is enabled in infinitely many markings occurs infinitely often in w. w is impartial w is fair w is fair w is just - 5 - Persistent nets Theorem 7: If the net is persistent, then every just execution is fair. - 6-8

State Fairness Theorem 8: Let N be a bounded net, t a live transition, and w a state-fair execution of N. Then t occurs infinitely often in w. - 7 - Extensions: finite capacities K(p)=4 t p 2 2 t 2 t 3-8 - 9

Extensions: Petri nets with priorities t t 2 : t 2 has higher priority than t. test t 2 t p p 0 Petri nets with priorities are Turing-complete. - 9 - Predicate/transition model of the dining philosophers problem Let x be one of the philosophers, let l(x) be the left fork of x, let r(x) be the right fork of x. p2 p p3 f f2 f3 Token: individuals. Semantics can be be defined by by replacing net by by equivalent condition/event net. Model can be be extended to to arbitrary numbers. - 20-0

Summary Petri nets Pros: Appropriate for distributed applications, Well-known theory for formally proving properties, Initially theoretical topic, but now widely adapted in practice due to increasing number of distributed applications. Cons (for the nets presented) : problems with modeling timing, no programming elements, no hierarchy. Extensions: Enormous amounts of efforts on removing limitations. - 2 - Data Flow Models - 22 -

Data flow modeling Def.: The process of identifying, modeling and documenting how data moves around an information system. Data flow modeling examines processes (activities that transform data from one form to another), data stores (the holding areas for data), external entities (what sends data into a system or receives data from a system, and data flows (routes by which data can flow). - 23 - Data flow as a natural model of applications Registering for courses Video on demand system http://www.agilemodeling.com/artifacts/dataflowdiagram.htm www.ece.ubc.ca/~irenek/techpaps/vod/vod.html - 24-2

Process networks Many applications can be specified in the form of a set of communicating processes. Example: system with two sensors: temperature sensor humidity sensor mux Alternating read loop read_temp; read_humidity until false; of the two sensors not the right approach. FIFO - 25 - The case for multi-process modeling in imperative languages MODULE main; TYPE some_channel = (temperature, humidity); some_sample : RECORD value : integer; line : some_channel END; PROCESS get_temperature; VAR sample : some_sample; BEGIN LOOP sample.value := new_temperature; IF sample.value > 30 THEN... sample.line := temperature; to_fifo(sample); END END get_temperature; PROCESS get_humidity; VAR sample : some_sample; BEGIN LOOP sample.value := new_humidity; sample.line := humidity; to_fifo(sample); END END get_humidity; BEGIN get_temperature; get_humidity; END; Blocking calls new_temperature, new_humidity Structure clearer than alternating checks for new values in a single process How to model dependencies between - 26 - tasks/processes? 3

Dependences between processes/tasks Get_temperature main FIFO Get_ humidity - 27 - Task graphs Sequence constraint Nodes are assumed to to be be a program described in in some programming language, e.g. C or or Java. Def.: A dependence graph is a directed graph G=(V,E) in which E V V is a partial order. If (v, v2) E, then v is called an immediate predecessor of v2 and v2 is called an immediate successor of v. Suppose E* is the transitive closure of E. If (v, v2) E*, then v is called a predecessor of v2 and v2 is called a successor of v. - 28-4

Reference model for data flow: Kahn process networks (974) For asynchronous message passing: communication between tasks is is buffered Special case: Kahn process networks: executable task graphs; Communication via infinitely large FIFOs - 29 - - 30-5

Properties of Kahn process networks () Each node corresponds to one program/task; Communication is only via channels; Channels include FIFOs as large as needed; Channels transmit information within an unpredictable but finite amount of time; Mapping from input seq. to output sequence; In general, execution times are unknown; Send operations are non-blocking, reads are blocking. One producer and one consumer; i.e. there is only one sender per channel; - 3 - Properties of Kahn process networks (2) There is only one sender per channel. A process cannot check whether data is available before attempting a read. A process cannot wait for data for more than one port at a time. Therefore, the order of reads depends only on data, not on the arrival time. Therefore, Kahn process networks are deterministic (!); for a given input, the result will always the same, regardless of the speed of the nodes. This is the key beauty of KPNs! - 32-6

A Kahn Process process f(in int u, in int v, out int w) { int i; bool b = true; u for (;;) { i = b? wait(u) : wait(w); f printf("%i\n", i); send(i, w); v b =!b; } Process alternately reads } from u and v, prints the data value, and writes it to w w Source: Gilles Kahn, The Semantics of a Simple Language for Parallel Programming (974) - 33 - A Kahn Process process f(in int u, in int v, out int w) { int i; bool b = true; for (;;) { i = b? wait(u) : wait(w); printf("%i\n", i); send(i, w); b =!b; } } wait() returns the next token in an input FIFO, blocking if it s empty send() writes a data value on an output FIFO Source: Gilles Kahn, The Semantics of a Simple Language for Parallel Programming (974) - 34-7

A Kahn Process process g(in int u, out int v, out int w) { v int i; bool b = true; for(;;) { u g i = wait(u); w if (b) send(i, v); else send(i, w); b =!b; } } Process reads from u and alternately copies it to v and w - 35 - A Kahn System Prints an alternating sequence of 0 s and s Emits a then copies input to output h g f h Emits a 0 then copies input to output - 36-8

Definition: Kahn networks A Kahn process network is a directed graph (V,E), where V is a set of processes, E V V is a set of edges, associated with each edge e is a domain D e D ω : finite of countably infinite sequences over D D ω is a complete partial order where X Y iff X is an initial segment of Y - 37 - Definition: Kahn networks e e e p v e q associated with each process v V with incoming edges e,, e p and outgoing edges e,,e q is a continuous function f v : D eω D ep ω D eω D eq ω (A function f: A B is continuous if f(lim A a) = lim B f(a) ) - 38-9

Semantics: Kahn networks A process network defines for each edge e E a unique sequence X e. X e is the least fixed point of the equations (X e,, X e q ) = f v (X e,, X eq ) for all v V. Result is independent of scheduling! - 39 - Scheduling Kahn Networks A (always produces token) C (only consumes from A) B (always produces token) D (always consumes token) Problem: run processes with finite buffer - 40-20

Scheduling may be impossible A (Two a s for every b ) a b B (Alternates between receiving a and b) - 4 - Parks Scheduling Algorithm (995) Set a capacity on each channel Block a write if the channel is full Repeat Run until deadlock occurs If there are no blocking writes terminate Among the channels that block writes, select the channel with least capacity and increase capacity until producer can fire. - 42-2

Example A (always produces token) C (only consumes from A) B (always produces token) D (always consumes token) - 43 - Parks Scheduling Algorithm Whether a Kahn network can execute in bounded memory is undecidable Parks algorithm does not violate this It will run in bounded memory if possible, and use unbounded memory if necessary Disadvantages: Requires dynamic memory allocation Does not guarantee minimum memory usage Scheduling choices may affect memory usage Data-dependent decisions may affect memory usage Relatively costly scheduling technique Detecting deadlock may be difficult - 44-22

Synchronous data flow (SDF) Asynchronous message passing= tasks do not have to wait until output is accepted. Synchronous data flow = all tokens are consumed at the same time. SDF model allows static scheduling of of token production and consumption. In In the general case, buffers may be be needed at at edges. - 45 - SDF: restriction of Kahn networks An SDF graph is a tuple (V, E, cons, prod, d) where V is a set of nodes (activities) E is a set of edges (buffers) cons: E N number of tokens consumed prod: E N number of tokens produced d: E N number of initial tokens d: delay (sample offset between input and output) - 46-23

Multi-rate SDF System DAT-to-CD rate converter Converts a 44. khz sampling rate to 48 khz 2 3 2 7 8 7 5 Upsampler Downsampler - 47 - SDF Scheduling Algorithm Lee/Messerschmitt 987. Establish relative execution rates Generate balance equations Solve for smallest positive integer vector c 2. Determine periodic schedule Form an arbitrarily ordered list of all nodes in the system Repeat: For each node in the list, schedule it if it is runnable, trying each node once If each node has been scheduled c n times, stop. If no node can be scheduled, indicate deadlock. Source: Lee/Messerschmitt, Synchronous Data Flow (987) - 48-24

Example A 4 3 2 3 D B 2 3 C 2 d(ca)=6-49 - Example 2 A B 2 C 3-50 - 25

Example 3 A B C 3 2 D - 5 - Example 4 A B - 52-26

Observations Consistent, connected systems have one-dimensional solution Disconnected systems have higher-dimensional solution Inconsistent systems have 0-schedule; otherwise infinite accumulation of tokens Systems may have multiple schedules - 53 - Summary dataflow Communication exclusively through FIFOs Kahn process networks blocking read, nonblocking write deterministic schedulability undecidable Parks scheduling algorithm SDF fixed token consumption/production compile-time scheduling: balance equations - 54-27