From Models to Code: The Missing Link in Embedded Software Tom Henzinger University of California, Berkeley Joint work with Ben Horowitz and Christoph.

Slides:



Advertisements
Similar presentations
Simulation of Feedback Scheduling Dan Henriksson, Anton Cervin and Karl-Erik Årzén Department of Automatic Control.
Advertisements

A Hierarchical Co-ordination Language for Interacting Real-time Tasks Arkadeb Ghosal, UC Berkeley Thomas A. Henzinger, EPFL Daniel Iercan, "Politehnica"
Lecture 8: Three-Level Architectures CS 344R: Robotics Benjamin Kuipers.
Undoing the Task: Moving Timing Analysis back to Functional Models Marco Di Natale, Haibo Zeng Scuola Superiore S. Anna – Pisa, Italy McGill University.
Overview: Chapter 7  Sensor node platforms must contend with many issues  Energy consumption  Sensing environment  Networking  Real-time constraints.
Introduction CSCI 444/544 Operating Systems Fall 2008.
Time Safety Checking for Embedded Programs Thomas A. Henzinger, Christoph M. Kirsch, Rupak Majumdar and Slobodan Matic.
The Fixed Logical Execution Time (FLET) Assumption Tom Henzinger University of California, Berkeley.
Model for Supporting High Integrity and Fault Tolerance Brian Dobbing, Aonix Europe Ltd Chief Technical Consultant.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
Event Driven Real-Time Programming CHESS Review University of California, Berkeley, USA May 10, 2004 Arkadeb Ghosal Joint work with Marco A. Sanvido, Christoph.
Chapter 13 Embedded Systems
Overview of PTIDES Project
Architecture Modeling and Analysis for Embedded Systems Oleg Sokolsky CIS700 Fall 2005.
Integrated Design and Analysis Tools for Software-Based Control Systems Shankar Sastry (PI) Tom Henzinger Edward Lee University of California, Berkeley.
Vertically Integrated Analysis and Transformation for Embedded Software John Regehr University of Utah.
April 16, 2009 Center for Hybrid and Embedded Software Systems PtidyOS: An Operating System based on the PTIDES Programming.
Chess Review May 11, 2005 Berkeley, CA Composable Code Generation for Distributed Giotto Tom Henzinger Christoph Kirsch Slobodan Matic.
Ritu Varma Roshanak Roshandel Manu Prasanna
Chapter 13 Embedded Systems
Scheduling with Optimized Communication for Time-Triggered Embedded Systems Slide 1 Scheduling with Optimized Communication for Time-Triggered Embedded.
Expressing Giotto in xGiotto and related schedulability problems Class Project Presentation Concurrent Models of Computation for Embedded Software University.
1 of 14 1 Analysis and Synthesis of Communication-Intensive Heterogeneous Real-Time Systems Paul Pop Computer and Information Science Dept. Linköpings.
Giotto A Time-Triggered Language for Embedded Programming Thomas A. Henzinger, Benjamin Horowitz Christoph M. Kirsch, Rupak Majumdar UC Berkeley.
NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI A New System Science.
NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Hybrid Systems: From.
Courseware Basics of Real-Time Scheduling Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens Plads, Building.
Interfaces for Control Components Rajeev Alur University of Pennsylvania Joint work with Gera Weiss (and many others)
Designing Predictable and Robust Systems Tom Henzinger UC Berkeley and EPFL.
November 18, 2004 Embedded System Design Flow Arkadeb Ghosal Alessandro Pinto Daniele Gasperini Alberto Sangiovanni-Vincentelli
CprE 458/558: Real-Time Systems
Software Issues Derived from Dr. Fawcett’s Slides Phil Pratt-Szeliga Fall 2009.
MOBIES Project Progress Report Engine Throttle Controller Design Using Multiple Models of Computation Edward Lee Haiyang Zheng with thanks to Ptolemy Group.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
Giotto and TMO Yerang Hur System Design Research Lab. Dept. of Computer and Information Science.
EMBEDDED SOFTWARE Team victorious Team Victorious.
Performance Evaluation of Real-Time Operating Systems
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 15 Slide 1 Real-time Systems 1.
0 Deterministic Replay for Real- time Software Systems Alice Lee Safety, Reliability & Quality Assurance Office JSC, NASA Yann-Hang.
Computer System Architectures Computer System Software
REAL-TIME SOFTWARE SYSTEMS DEVELOPMENT Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
1 CS 501 Spring 2003 CS 501: Software Engineering Lecture 16 System Architecture and Design II.
1 of 14 1/15 Synthesis-driven Derivation of Process Graphs from Functional Blocks for Time-Triggered Embedded Systems Master thesis Student: Ghennadii.
Scheduling policies for real- time embedded systems.
Giotto A tool-supported design methodology for developing hard real-time applications Cyber Physical Systems Lab Ramtin Raji Kermani.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing.
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
REAL-TIME SOFTWARE SYSTEMS DEVELOPMENT Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
> Power Supervison Desired Output level Source Diesel Valve Sink Diesel Valve > Valve Regulator Sink T = 40 ms Air Valve CBSE Course The SaveComp Component.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
CIS250 OPERATING SYSTEMS Chapter One Introduction.
CSCI1600: Embedded and Real Time Software Lecture 33: Worst Case Execution Time Steven Reiss, Fall 2015.
Chapter 1 Basic Concepts of Operating Systems Introduction Software A program is a sequence of instructions that enables the computer to carry.
Real-Time Operating System Design
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
T imed Languages for Embedded Software Ethan Jackson Advisor: Dr. Janos Szitpanovits Institute for Software Integrated Systems Vanderbilt University.
Agenda  Quick Review  Finish Introduction  Java Threads.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Giotto Embedded Control Systems Development with Thomas A. Henzinger Ben Horowitz Christoph M. Kirsch University of California, Berkeley
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Embedded Control System Development with Giotto Thomas A. Henzinger, Benjamin Horowitz, Christoph Meyer Kirsch UC Berkeley.
Muen Policy & Toolchain
Current Generation Hypervisor Type 1 Type 2.
Real-time Software Design
CSCI1600: Embedded and Real Time Software
Shanna-Shaye Forbes Ben Lickly Man-Kit Leung
Lecture Topics: 11/1 General Operating System Concepts Processes
CSCI1600: Embedded and Real Time Software
Presentation transcript:

From Models to Code: The Missing Link in Embedded Software Tom Henzinger University of California, Berkeley Joint work with Ben Horowitz and Christoph Kirsch

The History of Computer Science: Lifting the Level of Abstraction The “assembly age”: Programming to the platform High-level languages: Programming to the application Compilation: perhaps “the” success story of computer science It is feasible to abstract the platform.

The History of Computer Science: Lifting the Level of Abstraction The “assembly age”: Programming to the platform High-level languages: Programming to the application Automatic program synthesis: No more programming Compilation: perhaps “the” success story of computer science Code generation from specifications: still mostly a dream It is feasible to abstract the platform. It is not yet feasible to abstract algorithms.

Current Practice in Control Software Some manual programming to the platform Some automatic code generation from models -often inefficient -often unpredictable -difficult to reuse -difficult to verify -requires systems experts

Current Practice in Control Software Some manual programming to the platform Some automatic code generation from models The missing link: platform-independent software -often inefficient -often unpredictable -difficult to reuse -difficult to verify -requires systems experts

Advocated Practice in Control Software Executable code for a specific platform Mathematical model e.g. Simulink, HyTech Platform-independent software e.g. Giotto -verifiable -reusable -efficiently implementable Control engineer Compiler

Current Control Software Development Mathematical Model e.g. Simulink, HyTech Platform Constraints Executable Code -hardware configuration -RTOS (scheduling algorithm) -network protocol some automatic code generation, some manual code optimization -CONCURRENCY -ENVIRONMENT TIME -DISTRIBUTION -PLATFORM TIME

Current Control Software Development Mathematical ModelPlatform Constraints Executable Code Problems: -close correspondence between model and code is lost with code optimization -if either model or platform changes, the entire process needs to be repeated some automatic code generation, some manual code optimization

Mathematical Model Platform-independent Software Model e.g. Giotto Platform Constraints Executable Code -executable by virtual machine -composable An intermediate layer that separates platform-independent from platform- dependent software issues. Advocated Control Software Development

Mathematical Model Platform-independent Software Model Platform Constraints Executable Code e.g. What is the control equation? What is the sampling rate? e.g. Which procedure computes the control equation? Which event triggers the computation? e.g. Which CPU executes the control procedure? What priority has the execution? -still CONCURRENCY -still ENVIRONMENT TIME Advocated Control Software Development

Mathematical Model Platform-independent Software Model Platform Constraints Executable Code Platform-independent programming i.e. algorithms and data structures Platform-dependent code generation e.g. priorities SEPARATION OF CONCERNS !!! Advocated Control Software Development

Motivation: Flight Control Software ETH Zurich (Kirsch, Pree, Sanvido, Schaufelberger, Wirth). Single CPU.

Motivation: Flight Control Software UC Berkeley (Horowitz, Liebman, Ma, Koo, Sangiovanni-Vincentelli, Sastry). Two connected CPUs.

Motivation: Flight Control Software

200 Hz 400 Hz 200 Hz 1 kHz Motivation: Flight Control Software

1. Concurrent periodic tasks: -sensing -control law computation -actuating 2. Multiple modes of operation: -navigational modes (autopilot, manual, etc.) -maneuver modes (taxi, takeoff, cruise, etc.) -degraded modes (sensor, actuator, CPU failures) Platform-independent Software Model

Mode 1 Mode 4Mode 3 Mode 2 Task S 400 Hz Task C 200 Hz Task A 1 kHz Task S 400 Hz Task C 200 Hz Task A’ 1 kHz Task C’ 100 Hz Task A 1 kHz Task S 400 Hz Task C 200 Hz Task A 2 kHz Task A” 1 kHz Condition 1.2 Condition 2.1 Platform-independent Software Model

Host code e.g. C Glue code Giotto Functionality. -Environment time, not platform time. -Concurrency, not distribution. Platform-independent Software Model Timing and interaction. This kind of software is understood: Host code may (sometimes) be generated automatically. The software complexity lies in the glue code (minimize jitter!) : Giotto enables requirements-driven rather than platform-driven glue-code programming. -No time. -Sequential.

1. The Giotto Programmer’s Model 2. The Giotto Compiler

The Giotto Programmer’s Model Programming in terms of environment time: Programmer’s fiction: -time-triggered task invocation -tasks are functions with a fixed duration -platform offers sufficient performance Implementation in terms of platform time: Compiler must maintain programmer’s fiction: -needs access to global time, no other platform requirements -tasks may finish early, but outputs cannot be observed early -tasks may be preempted and distributed

Given: 1. Units of scheduled host code (application-level tasks). e.g. control law computation 2. Units of synchronous host code (system-level drivers). e.g. device drivers 3. Real-time requirements and data flow between tasks. Giotto: Glue code that calls 1. and 2. in order to realize 3. Task Input portsOutput ports Task Task driver loads task input ports. The Giotto Programmer’s Model

Task Driver Input ports loaded. Driver execution in environment time 0. Task execution in environment time d. Output ports read. Sensor/output ports read. Sensor Actuator Actuator/input ports loaded. Time t Time t+d d Task duration Environment Timeline (defined by Giotto semantics)

Task Driver Input ports loaded. Output ports read. Sensor Time t Time t+d d Task on CPU. Actuator Platform Timeline (chosen by Giotto compiler)

The Giotto compiler chooses for a given platform a platform timeline that is value equivalent to the environment timeline defined by the Giotto semantics. Internal Determinism: For a given sequence of sensor readings, the corresponding sequence of actuator settings is uniquely determined (i.e., there are no race conditions). Platform Independence ensures Predictability

Navigation Control Simplified Helicopter Software Sensors Actuators i s a 10 5

Navigation Control Simplified Helicopter Software Sensors Actuators i s a 10 5 Matlab/legacy design

aia t+10ms s Task Navigation Control t+10ms tt t+5ms i ss Helicopter Software: Environment Timeline Block of synchronous code (nonpreemptable) Scheduled tasks (preemptable)

t+10ms Task t+10ms tt t+5ms Single-CPU Helicopter: Platform Timeline (EDF)

t+10ms ttt+5ms t+7ms HeliCtr HeliNav TDMA Slot HeliNet Two-CPU Helicopter: Platform Timeline (Time-triggered Communication)

t+10mstt t+5ms HeliCtr HeliNav Message HeliNet Two-CPU Helicopter: Platform Timeline (Event-triggered Communication) t+10ms

sensor gps_type GPS uses c_gps_device ; actuator servo_type Servo := c_servo_init uses c_servo_device ; output ctr_type CtrOutput := c_ctr_init ; nav_type NavOutput := c_nav_init ; driver sensing (GPS) output (gps_type gps) { c_gps_pre_processing ( GPS, gps ) } task Navigation (gps_type gps) output (NavOutput) { c_matlab_navigation_code ( gps, NavOutput ) } … Helicopter Software: Giotto Syntax (Functionality)

… mode Flight ( ) period 10ms { actfreq 1 do Actuator ( actuating ) ; taskfreq 1 do Control ( input ) ; taskfreq 2 do Navigation ( sensing ) ; } … Helicopter Software: Giotto Syntax (Timing)

Mode Switch f hg f Mode m Mode m’ d d’ p  s 5

ppd Task g f Mode t+5ms Time Mode Switch: Environment Timeline

pdp Mode Switch t+5ms Task g f Time s Mode Switch: Environment Timeline

d’pdp Task g f Time t+5ms s Mode Switch: Environment Timeline

pdsphd’ Task g f Time t+7.5mst+5ms Mode Switch: Environment Timeline

sdppd’ t+10ms hd’h Task g f Mode Switch: Environment Timeline t+10ms

1. The Giotto Programmer’s Model 2. The Giotto Compiler

The Giotto Compiler Giotto Program Native Code Tasks and Drivers Giotto-P Platform Specification -topology (CPUs, nets) -performance (WCETs, latencies) -APIs (RTOSs, protocols) Executables Giotto Compiler Functionality Timing Interaction Platform “Failure” either Giotto-P overconstrained, or compiler not smart enough (distributed scheduling problem) or

Closing the Gap: Annotated Giotto Giotto Program Native Code Tasks and Drivers Giotto-P -topology (CPUs, nets) -performance (WCETs, latencies) -APIs (RTOSs, protocols) Executables Giotto Compiler Functionality Timing Interaction Platform “Failure” either Giotto-PM overconstrained, or compiler not smart enough (global scheduling problem) or Giotto-PM -assign tasks to CPUs -assign connections to nets Map

Closing the Gap: Annotated Giotto Giotto Program Native Code Tasks and Drivers Giotto-P Executables Giotto Compiler Functionality Timing Interaction Platform “Failure” Giotto-PMC overconstrained (local scheduling problems solvable) or Giotto-PM Map Giotto-PMC Communication -assign connections to TDMA slots (say) -topology (CPUs, nets) -performance (WCETs, latencies) -APIs (RTOSs, protocols) -assign tasks to CPUs -assign connections to nets

Single-CPU Giotto Scheduling Why is it simple? -Static utilization test for each mode -Mode switches are memory-free Theorem: Given a Giotto program and WCETs for all tasks, it can be checked in quadratic time if an EDF scheduler meets all deadlines.

[ host HeliCtr address ; host HeliNav address ; network HeliNet address connects HeliCtr, HeliNav ] … mode Flight ( ) period 10ms { actfreq 1 do Actuator ( actuating ) ; taskfreq 1 do Control ( input ) [ host HeliCtr ] ; taskfreq 2 do Navigation ( sensing ) [host HeliNav; push ( NavOutput ) to ( HeliCtr ) in HeliNet slots (7,10) ] ; } … Two-CPU Helicopter: Annotated Giotto (Time-triggered Communication)

Code Generation Giotto Program Native Code Tasks and Drivers Giotto-P Giotto Compiler Functionality Timing Interaction Platform Giotto-PM Map Giotto-PMC Communication -assign connections to TDMA slots (say) -topology (CPUs, nets) -performance (WCETs, latencies) -APIs (RTOSs, protocols) -assign tasks to CPUs -assign connections to nets or “Failure” VxWorksOSEK …

Code Generation: The Embedded Machine Giotto Program Native Code Tasks and Drivers Giotto-P Embedded Machine code Giotto Compiler Functionality Timing Interaction Platform or Giotto-PM Map Giotto-PMC Communication -assign connections to TDMA slots (say) -topology (CPUs, nets) -performance (WCETs, latencies) -APIs (RTOSs, protocols) -assign tasks to CPUs -assign connections to nets “Failure” Embedded Machine interpreter

The Embedded Machine -a virtual machine that mediates the interaction of physical processes (sensors and actuators) and software processes (tasks and drivers) in real time -the Giotto compiler can be retargeted to a new platform by porting the Embedded Machine

Environment Software Software Processes: platform time Environment Processes: environment time The Embedded Machine

Environment Software Schedulability Reactivity The Embedded Machine The Art of Embedded Programming

Environment Software Schedulability: time safety checking for platform time Reactivity: programming in environment time (e.g. Giotto) The Embedded Machine: Time is like Memory Embedded Machine

Environment Ports Task Ports Driver Ports Embedded Machine task triggers environment triggers sense actuate read write call drivers The Embedded Machine schedule tasks e.g. clock e.g. task completion

Enable trigger: future( g,B:) B: Schedule task: schedule( T ) T Call driver: call( d ) d g The Embedded Machine: Three Instructions Execute driver d now. Hand task t over to the system scheduler (RTOS). Have code B executed as soon as trigger g becomes true.

ai a t+10ms s Task Navigation Control t+10ms ttt+5ms i ss B1:call( actuate ) call( sense ) call( input ) schedule( Control ) schedule( Navigation ) future( now+5, B2:) relax Giotto Code Generation: The Embedded Machine

ai a t+10ms s Task Navigation Control t+10ms tt t+5ms i ss B2:call( sense ) schedule( Navigation ) future( now+5, B1:) relax Giotto Code Generation: The Embedded Machine

The Embedded Machine Synchronous code: -Embedded Machine instructions and drivers -kernel context (trigger-related interrupts disabled) Scheduled code: -tasks -user context (trigger-related interrupts enabled)

The Embedded Machine Task-triggered code: -triggers on environment and task ports -observable behavior depends on environment and scheduler Environment-triggered code: -triggers only on environment ports -observable behavior depends on environment only All Giotto programs result in environment-triggered code.

The Embedded Machine Time-safe code: No driver accesses a scheduled task before completion. Time-live code: There is no infinite synchronous computation. All Giotto programs result in time-live code. Time safety is checked by the Giotto compiler. Alternatively, time safety violations can be can be handled through run-time exceptions.

The Embedded Machine Time Safety: Violations due to combination of -insufficient synchrony (environment events too frequent) -insufficient platform utilization (scheduler too weak) -insufficient platform performance (hardware too slow) Our approach therefore systematically integrates synchronous programming and scheduling theory.

The Giotto Project Completed: -Software tools: Simulink to Giotto translator (Kirsch, Pree) Giotto compiler for single-CPU targets (Kirsch) Embedded Machine for Linux and VxWorks (Kirsch) -Applications: Lego Mindstorms (Horowitz, Kirsch, Majumdar) Zurich helicopter (Kirsch, Sanvido) In progress: -Software tools: Giotto scheduler for distributed platforms (Horowitz) Time safety checker for Embedded Machine code (Kirsch, Matic) -Applications: Berkeley helicopter (Horowitz, Liebman, Ma) Electronic throttle control (Kirsch)