CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur...

23
CIS 540 Principles of Embedded Computation Spring 2014 http://www.seas.upenn.edu/~cis540/ Instructor: Rajeev Alur [email protected]

Transcript of CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur...

Page 1: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

CIS 540Principles of Embedded Computation

Spring 2014 http://www.seas.upenn.edu/~cis540/

Instructor: Rajeev [email protected]

Page 2: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Embedded Software Systems Everywhere!

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Software Inside

Page 3: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

From Desktops to Cyber-Physical Systems

Traditional computers: Stand-alone device running software applications (e.g. data processing)

Traditional controllers: Devices interacting with physical world via sensors and actuators (e.g. thermostat)

Embedded Systems Special-purpose system with integrated

microcontroller/software Cameras, watches, washing machines…

Cyber-physical systems Computing devices communicating with one another and

interacting with the physical world via sensors/actuators Computing + Control + Communication Example: Team of autonomous robots

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 4: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Foundations of Cyber-Physical Systems

CPS emerging as a distinct academic discipline recently Conferences: Embedded Systems Week, Cyber-Physical Systems Week Research priority for Government agencies

CPS in industry Technologies for low-cost devices available, but… Challenge: Managing complexity to produce reliable systems

Foundations for traditional computing Limits of computation: Turing machines … Efficiency of problem solving: Algorithms and complexity Correctness: Formal specification and verification Complexity of software: Programming abstractions

Does design of CPS need new theoretical foundations? What are the distinguishing features of CPS?

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 5: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Functional vs Reactive Computation

Classical model of computation: Functional Given inputs, a program produces outputs Desired functionality described by a mathematical function Example: Sorting of names, Shortest paths in a weighted graph Theory of computation provides foundation for this view

Reactive System interacts with its environment via inputs and

outputs in an ongoing manner Desired behaviors: which sequences of observed

input/output interactions are acceptable? Example: Cruise controller in a car

CPS: Reactive

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 6: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Sequential vs Concurrent Computation

Classical model of computation: Sequential A computation is a sequence of instructions executed one at a time Well understood and canonical model: Turing machines

Concurrent Computation Multiple components/processes exchanging information and

evolving concurrently Logical vs physical concurrency Broad range of formal models for concurrent computation Key distinction: Synchronous vs Asynchronous

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 7: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Feedback Control of the Physical World

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Discrete Control(Software)

Physical Plant(Continuous Dynamics)

Sensors Actuators

Classical control theory: Continuous-time systems Key ingredient: Modeling of dynamical systems by differential

equations Theory of linear systems for design and analysis

Hybrid systems: Discrete + continuous dynamics Multiple modes of operation Discrete software

Page 8: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Real-Time Computation

Traditional computing infrastructure (programming languages, operating systems, and processor architecture) do not support real time explicitly Efficient, flexible and portable implementations Suitable for general purpose computing tasks, but not for

CPS Real-Time

Timing of events critical to correctness Need a way to predict and model delays at design time Key: Predictable and timely performance Need to worry about resource contention and allocation

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 9: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Safety-Critical Applications

Traditional verification and validation approach Design, implementation, followed by extensive testing Software bugs are common-place Fixing of bugs can be expensive

Safety-critical applications Bugs lead to catastrophic failures Establishing correctness at design time a high priority

Formal methods Formalize correctness requirements in a precise manner Develop a model of system and its environment at design

time Establish that the system meets the requirements

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 10: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Ariane 5 Explosion

“It took the European Space Agency 10 years and $7 billion to produce Ariane 5. All it took to explode that rocket less than a minute into its maiden voyage last June, scattering fiery rubble across the mangrove swamps of French Guiana, was a small computer program trying to stuff a 64-bit number into a 16-bit space”

A bug and a crash, J. Gleick, New York Times, Dec 1996

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 11: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Prius Brake Problems Blamed on Software Glitches

“Toyota officials described the problem as a "disconnect" in the vehicle's complex anti-lock brake system (ABS) that causes less than a one-second lag. With the delay, a vehicle going 60 mph will have traveled nearly another 90 feet before the brakes begin to take hold”

CNN Feb 4, 2010

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 12: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Software: The Achilles’ Heel

Software everywhere means bugs everywhere2002 study by NIST:

Software bugs cost US economy $60 billion annually (0.6% of GDP)

Lack of trust in software as technology barrier

Would you use an autonomous software-controlled round-the-clock monitoring and drug-delivery device?

Grand challenge for computer science:Technology for designing “correct” cyber-physical systems

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 13: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Course Topics

Goal: Introduction to principles of design, specification, analysis and implementation of CPS

Disciplines Model-based design Concurrency theory Distributed algorithms Formal specification Verification techniques and tools Control theory Real-time systems Hybrid systems

Emphasis on mathematical concepts

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 14: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Theme 1: Formal Models

Mathematical abstractions to describe system designs Modeling formalisms

Synchronous models (Chapter 2) Asynchronous models (Chapter 4) Continuous-time dynamical systems (Chapter 5) Timed models (Chapter 7) Hybrid systems (Chapter 9)

Modeling concepts Syntax vs semantics Composition Input/output interfaces Nondeterminism, fairness, …

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 15: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Theme 2: Specification and Analysis

Formal techniques to ensure correctness at design time Requirements

Safety (invariants, monitors) Liveness (temporal logic, automata over infinite sequences) Stability Schedulability

Analysis techniques Deductive: Inductive invariants and ranking functions Enumerative and symbolic search for state-space

exploration Model checking Linear-algebra-based analysis of dynamical systems Verification of timed and hybrid systems

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 16: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Theme 3: Model-based Design

Design and analysis of illustrative computing problems Design methodology

Structured modeling (bottom-up, top-down) Requirements-based design and design-space exploration

Case studies Distributed coordination: mutual exclusion, consensus,

leader election Communication: Reliable transmission, synchronization Control design: PID, cruise controller CPS: Obstacle avoidance for robots, multi-hop control

network

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 17: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Course Logistics (1)

TA: Rahul Vasist (rahulr@seas) Office Hours: Alur 4-5 Tues(Levine 609); Rahul Mon 4-5 Recitation: Fridays 12 -1 (starting Jan 24)

Review + Problem solving + Question/Answer Grading

Six Homeworks (theory problems): 30% Three Projects (Modeling + Analysis Tools): 15% Midterm (March 5, in-class): 20% Final Exam (May 9): 35%

Avoid all forms of academic cheating! If stuck, contact me or Rahul

Course participation Ask questions! Answer questions! Use of laptops, mobile phones etc during class is not allowed

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 18: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Course Logistics (2)

Textbook: Principles of Cyber-Physical Systems Draft copy available Email me comments, corrections …

Complementary courses and course material Introduction to embedded systems; Lee/Seshia,UC Berkeley Foundations of cyber-physical systems; Platzer, CMU

Modeling/analysis software SPIN model checker MATLAB Stateflow/Simulink by Mathworks

Theory course Emphasis on Abstract thinking + Rigorous reasoning

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 19: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Model-Based Design

Block Diagrams Widely used in industrial design Tools: Simulink, Modelica, RationalRose…

Key question: what is the execution semantics? What is a base component How do we compose components to form complex

components?

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 20: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Synchronous Models

All components execute in a sequence of (logical) rounds in a lock-step manner

Example: Component blocks in digital hardware circuit Clock drives all components in a synchronized manner

Key idea in synchronous languages: Design system using such a synchronous round-based

computation Benefit: Design is simpler (why?) Challenge: Implementation platform need not be

synchronous single-chip hardware CPS example: time-triggered CAN bus for communication

in a modern automobile

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

Page 21: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

First Example: Delay

Input variable: in of type Boolean

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

bool in bool outbool x := 0

out:=x ; x:= in

Output variable: in of type Boolean

State variable: x of type Boolean

Initialization of state variables: assignment x:=0

In each round, in response to an input, produce output and update state by executing the update code: out:=x; x:=in

Page 22: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Delay: Round-based Execution

Initialize state to 0

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15

bool inbool x := 0

out:=x ; x:= in

Repeatedly execute rounds. In each round:Choose a value for the input variable inExecute the update code to produce output out and change

state

Sample execution:

0 1 / 0

11 / 1

10 / 1

00 / 0

01 / 0

1

bool out

Page 23: CIS 540 Principles of Embedded Computation Spring 2014 cis540/ Instructor: Rajeev Alur alur@cis.upenn.edu.

Synchrony Hypothesis

Assumption: The time needed to execute the update code is negligible compared to delay between successive input arrivals

Logical abstraction: Execution of update code takes zero time Production of outputs and reception of inputs occurs at same

time When multiple components are composed, all execute

synchronously and simultaneously Implementation must make sure that this design-time

assumption is valid

CIS 540 Principles of Embedded Computation; Spring 2014; Lecture Jan 15