Safe Programming of Asynchronous Interaction: Can we do it for real? Shaz Qadeer Research in Software Engineering Microsoft Research.

Slides:



Advertisements
Similar presentations
Implementation and Verification of a Cache Coherence protocol using Spin Steven Farago.
Advertisements

purpose Search : automation methods for device driver development in IP-based embedded systems in order to achieve high reliability, productivity, reusability.
Reliable Scripting Using Push Logic Push Logic David Greaves, Daniel Gordon University of Cambridge Computer Laboratory Reliable Scripting.
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Software Requirements Engineering
Reporter:PCLee With a significant increase in the design complexity of cores and associated communication among them, post-silicon validation.
Chapter 7 Protocol Software On A Conventional Processor.
Model Checking. Used in studying behaviors of reactive systems Typically involves three steps: Create a finite state model (FSM) of the system design.
Concurrency CS 510: Programming Languages David Walker.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Lock Inference for Systems Software John Regehr Alastair Reid University of Utah March 17, 2003.
Active Messages: a Mechanism for Integrated Communication and Computation von Eicken et. al. Brian Kazian CS258 Spring 2008.
3.5 Interprocess Communication
Software Engineering, COMP201 Slide 1 Protocol Engineering Protocol Specification using CFSM model Lecture 30.
CS533 - Concepts of Operating Systems
Verifying Distributed Real-time Properties of Embedded Systems via Graph Transformations and Model Checking Gabor Madl
November 18, 2004 Embedded System Design Flow Arkadeb Ghosal Alessandro Pinto Daniele Gasperini Alberto Sangiovanni-Vincentelli
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
SE-565 Software System Requirements More UML Diagrams.
Chapter 4.1 Interprocess Communication And Coordination By Shruti Poundarik.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Advances in Language Design
02/06/05 “Investigating a Finite–State Machine Notation for Discrete–Event Systems” Nikolay Stoimenov.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
Towards Scalable Modular Checking of User-defined Properties Thomas Ball, MSR Brian Hackett, Mozilla Shuvendu Lahiri, MSR Shaz Qadeer, MSR Julien Vanegue,
Architectural Design portions ©Ian Sommerville 1995 Establishing the overall structure of a software system.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 10Slide 1 Architectural Design l Establishing the overall structure of a software system.
Rebecca Modeling Language Mahdieh Ahmadi Verification of Reactive Systems March 2014.
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.
Architecting Web Services Unit – II – PART - III.
Scientific Computing By: Fatima Hallak To: Dr. Guy Tel-Zur.
CS4730 Real-Time Systems and Modeling Fall 2010 José M. Garrido Department of Computer Science & Information Systems Kennesaw State University.
SOFTWARE DESIGN.
Programming Models & Runtime Systems Breakout Report MICS PI Meeting, June 27, 2002.
Framework for the Development and Testing of Dependable and Safety-Critical Systems IKTA 065/ Supported by the Information and Communication.
- 1 - Embedded Systems - SDL Some general properties of languages 1. Synchronous vs. asynchronous languages Description of several processes in many languages.
Advanced Computer Networks Topic 2: Characterization of Distributed Systems.
Refining middleware functions for verification purpose Jérôme Hugues Laurent Pautet Fabrice Kordon
Programming Paradigms for Concurrency Pavol Cerny Vasu Singh Thomas Wies Part III – Message Passing Concurrency.
1 Qualitative Reasoning of Distributed Object Design Nima Kaveh & Wolfgang Emmerich Software Systems Engineering Dept. Computer Science University College.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
RELIABILITY ENGINEERING 28 March 2013 William W. McMillan.
Synchronization and semaphores Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CS4730 Real-Time Systems and Modeling Fall 2010 José M. Garrido Department of Computer Science & Information Systems Kennesaw State University.
Xiong Junjie Node-level debugging based on finite state machine in wireless sensor networks.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Course: COMS-E6125 Professor: Gail E. Kaiser Student: Shanghao Li (sl2967)
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
Formal Verification. Background Information Formal verification methods based on theorem proving techniques and model­checking –To prove the absence of.
OOD OO Design. OOD-2 OO Development Requirements Use case analysis OO Analysis –Models from the domain and application OO Design –Mapping of model.
SystemC Semantics by Actors and Reduction Techniques in Model Checking Marjan Sirjani Formal Methods Lab, ECE Dept. University of Tehran, Iran MoCC 2008.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
Copyright 1999 G.v. Bochmann ELG 7186C ch.1 1 Course Notes ELG 7186C Formal Methods for the Development of Real-Time System Applications Gregor v. Bochmann.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 10Slide 1 Chapter 5:Architectural Design l Establishing the overall structure of a software.
The Structuring of Systems Using Upcalls By David D. Clark Presented by Samuel Moffatt.
Principles of Programming & Software Engineering
Support for Program Analysis as a First-Class Design Constraint in Legion Michael Bauer 02/22/17.
Complexity Time: 2 Hours.
Hierarchical Architecture
Chapter 20 Object-Oriented Analysis and Design
Synchronization and semaphores
Chapter 2: Building a System
Presentation transcript:

Safe Programming of Asynchronous Interaction: Can we do it for real? Shaz Qadeer Research in Software Engineering Microsoft Research

Asynchronous interaction Collection of state machines communicating asynchronously via message buffers – distributed algorithms – cloud infrastructure, services, and applications – event-driven JavaScript/AJAX programs – device drivers – …

Challenging characteristics Decomposition of a logical task into pieces Temporally overlapped execution of tasks Failure tolerance is important Coordination via protocols

Safety-critical is so 20 th century Software should just “work” – as cloud computing becomes common – as devices get embedded into everyday life First-order concerns – software reliability – programming, testing, and debugging productivity – cost of achieving reliability and productivity Need programming techniques to improve reliability and productivity

Outline Formal design of USB device driver stack in Windows 8 Challenges (or inspiration) for the future Domain-specific language, compiler, and verifier for protocol programming

What is USB? Universal Serial Bus Primary mechanism for connecting peripherals to PCs – 2 billion USB devices sold every year (as of 2008) – voted most important PC innovation of all time (PC magazine) USB 1.0USB 2.0USB 3.0

USB device driver stack in Win8 HSM PSM OS, drivers Hardware DSM

Design methodology (Aull-Gupta) State Machine In Visio State Table, Transitions And State Entry Functions In C Operations In C State Machine Engine In C Script State Table, Transitions And State Entry Functions In Zing State Machine Engine In Zing Document Operations, Rules And Assumptions Program Operations, Rules And Assumptions In Zing Script

Assumptions/Guarantees Upon calling TimerStart(), machine could receive TimerFired event – S1, S2, and S3 need to handle TimerFired Upon receiving TimerFired, machine will not receive TimerFired – S4 does not need to handle TimerFired State S1 TimerStart() State S2 State S3State S4 X TimerFired Y

Timer state machine

Zing error trace Check failed ******************************************************************************* Send(chan='Microsoft.Zing.Application+___EVENT_CHAN(12)', data='___StartTimer') Receive(chan='Microsoft.Zing.Application+___EVENT_CHAN(12', data='___StartTimer') AttributeEvent: Handled Event ___StartTimer, Old State: ___WaitingForCommand, New State: ___StartingTimer Send(chan='Microsoft.Zing.Application+___EVENT_CHAN(12)', data='___TimerFired') Send(chan='Microsoft.Zing.Application+___EVENT_CHAN(12)', data='___StopTimer') AttributeEvent: Handled Event ___OperationSuccess, Old State: ___StartingTimer, New State: ___WaitingForTimerToExpire Receive(chan='Microsoft.Zing.Application+___EVENT_CHAN(12', data='___TimerFired') AttributeEvent: Handled Event ___TimerFired, Old State: ___WaitingForTimerToExpire, New State: ___SignallingTimerCompletion AttributeEvent: Handled Event ___OperationSuccess, Old State: ___SignallingTimerCompletion, New State: ___WaitingForCommand Receive(chan='Microsoft.Zing.Application+___EVENT_CHAN(12', data='___StopTimer') AttributeEvent: HSM-1: Unhandled Event ___StopTimer, State ___WaitingForCommand ] Error in state: Zing Assertion failed: Expression: false Comment: Unhandled Event Depth on error 208

Impact Unprecedented use of formal design in Windows Model is the Source Over 200 rules to catch regression bugs even before C Code is compiled Over 300 bugs found and fixed – unhandled messages, property violations State machine# states# transitions#bugs HSM PSM PSM DSM

Benefits Model verification complements testing – validates states that are hard to reach with testing – debugging is significantly easier Explicit specification of contracts – solid design – better documentation and maintenance

Difficulties faced by programmers Visio inadequate container for state diagrams Semantics of modeling language embedded inside scripts No automation for managing properties, models, and lemmas

From modeling to programming State machine models are programs in a domain- specific language (DSL) Develop a modern programming environment for a DSL inspired by state machines – Simple syntax/semantics for programs and properties – Code generator and runtime library for execution – Verifier for property checking

Ping Pong machine Ping receives pong { var x: Pong state ( start, x := new Pong(y = this); raise unit ) ( ping1, send(x, ping); return ) transition ( start, unit, ping1 ) ( ping1, pong, ping1 ) } machine Pong receives ping { var y: Ping state ( start, return ) ( pong1, send(y, pong); raise unit ) transition ( start, ping, pong1 ) ( pong1, unit, start ) }

x := new Pong; raise unit send(x, ping); return unit pong

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit ping

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit pong

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit pong

x := new Pong; raise unit send(x, ping); return unit pong return send(that, pong); raise unit pingunit

Unhandled events Suppose state s only provides the transitions (s, e1, s1) and (s, e2, s2) Retrieving e3 from input queue results in UnhandledEventException Absence of UnhandledEventException must be verified

Deferred events State (s, Stmt, {e1, e2}) s is in the middle of critical processing waiting for e Presence of e1 and e2 in the buffer does not cause UnhandledEventException e1 and e2 are skipped over while retrieving e

Sub-state machines Statement “call s” pushes state s on the machine stack – s will handle a sub-protocol Sub-computation inherits deferred events from the caller Caller given a chance to handle UnhandledEventException

Memory management When is it safe to free up the memory for a state machine? Reference counting: Increment, Decrement A machine is freed only when – its reference count is zero – it is quiescent Accessing a freed machine causes IllegalAccessException whose absence must be verified

Runtime library Provides support for – machine creation and deletion – input buffer management – execution of transitions and entry functions Reactive event-driven computation piggybacked on external threads – locking for coordination among multiple external threads executing within the runtime

Verification How do we verify the absence of UnhandledEventException and IllegalAccessException? How do we verify program-specific properties? How do we specify interfaces?

Automata Automata are used to model implementation and specification. A B Set of states AlphabetInitial state Automata

Parallel composition is the synchronous product. (trace intersection) A B A C A B B C C Shared transition Local transition Parallel composition

Properties Specifications are monitors that define the set of allowed traces. An implementation is correct if it refines the specifications. Refinement is trace inclusion. A B B A B B Properties

Semantic gap How do we connect a program to a finite collection of automata communicating via rendezvous over a finite alphabet? Challenges – dynamic creation of machines – asynchronous message passing – unbounded input buffers

Solution Dynamic machine creation – finite verification scenario Asynchronous message passing – separate events for sending and receiving – events tagged by sender and receiver machine ids

Send AReceive BReceive A Send B Send A Receive A Send B Receive B Implementations (machines and channels) Ping Ping Buffer Pong Pong Buffer

Solution Dynamic machine creation – finite verification scenario Asynchronous message passing – separate events for sending and receiving – events tagged by sender and receiver machine ids Unbounded input buffers – compositional verification – finite-state buffer abstractions

Compositional verification

Simple hierarchical case Hierarchical compositional rule

Send AReceive BReceive A Send B Send A Receive A Send B Receive B Send A Receive A Send B Receive B Implementations (machines and channels) Specification

Decomposing by weakening AB Weaken by A AB A A SWeaken(S, A) S = Weaken(S, A) || Weaken(S, B)

Circular compositional rule

Receive A Send B Send A Receive A Send B Receive B Send A Receive A Send B Receive B Send B refines Pong

Review A domain-specific language for programming protocol aspects of asynchronous computations – operational semantics – compiler/runtime for device driver domain – verification

Work in progress Deliver working prototype to Windows and third-party driver developers Other applications – cloud infrastructure, services, and applications – networking software – asynchronous web programming – …

Opportunity Transform protocol design and implementation across a variety of application domains Target the greatest threat to software reliability in the era of pervasive devices and pervasive distributed computing