Tracelets: a Model for the Laws of Concurrent Programming Tony Hoare OxfordFeb 2012.

Slides:



Advertisements
Similar presentations
การทดสอบโปรแกรม กระบวนการในการทดสอบ
Advertisements

COMMUNICATING SEQUENTIAL PROCESSES C. A. R. Hoare The Queen’s University Belfast, North Ireland.
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
1 Written By: Adi Omari (Revised and corrected in 2012 by others) Memory models CDP Tutorial 7.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
1 Partial Order Reduction. 2 Basic idea P1P1 P2P2 P3P3 a1a1 a2a2 a3a3 a1a1 a1a1 a2a2 a2a2 a2a2 a2a2 a3a3 a3a3 a3a3 a3a3 a1a1 a1a1 3 independent processes.
1 Lecture 20 Sequential Circuits: Latches. 2 Overview °Circuits require memory to store intermediate data °Sequential circuits use a periodic signal to.
Probability Theory Part 1: Basic Concepts. Sample Space - Events  Sample Point The outcome of a random experiment  Sample Space S The set of all possible.
 Recap – Python Basics. Python  Python is an interpreter which reads and executes a python script.  A python script is a text file, which contains.
Representing Relations Using Matrices
Algebra unifies calculi of programming Tony Hoare Feb 2012.
12 VECTORS AND THE GEOMETRY OF SPACE.
12.1 Systems of Linear Equations: Substitution and Elimination.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
CS5371 Theory of Computation
Ordering and Consistent Cuts Presented By Biswanath Panda.
Execution of an instruction
CPSC 668Set 16: Distributed Shared Memory1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Tucker, Applied Combinatorics, Section 1.4, prepared by Patti Bodkin
Concurrency CS 510: Programming Languages David Walker.
Chapter 11: Distributed Processing Parallel programming Principles of parallel programming languages Concurrent execution –Programming constructs –Guarded.
CS533 - Concepts of Operating Systems
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
CS510 Concurrent Systems Class 5 Threads Cannot Be Implemented As a Library.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
1 COMP541 Combinational Logic - II Montek Singh Aug 27, 2014.
Introduction to Logic Logical Form: general rules
Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
© 2009 Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen 1 Concurrency in Programming Languages Matthew J. Sottile Timothy G. Mattson Craig.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
Aquinas Hobor and Cristian Gherghina (National University of Singapore) TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Charts and nets: States, Messages, and Events Tony Hoare In honour of David Harel ViennaJuly 2014.
1 Concurrent Languages – Part 1 COMP 640 Programming Languages.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Extending Trace Models Tony Hoare Ian Wehrman. Traces Trace: set of events + dependency relation – an execution of a program tr.
Homework Review notes Complete Worksheet #1. Homework Let A = {a,b,c,d}, B = {a,b,c,d,e}, C = {a,d}, D = {b, c} Describe any subset relationships. 1.
CS6133 Software Specification and Verification
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Lecture 22: 11/19/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computing Fundamentals 2 Lecture 6 Probability Lecturer: Patrick Browne
Execution of an instruction
ELIMINATING LEFT RECURSIVENESS. Abbreviation. “cfg” stands for “context free grammar” Definition. A cfg is left recursive if it contains a production.
Petri Nets Lecturer: Roohollah Abdipour. Agenda Introduction Petri Net Modelling with Petri Net Analysis of Petri net 2.
Laws of concurrent design Tony Hoare Microsoft ResearchCambridge FMCAD October.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
An Axiomatic Basis for Computer Programming Robert Stewart.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Functions (Mappings). Definitions A function (or mapping)  from a set A to a set B is a rule that assigns to each element a of A exactly one element.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS Fall 2011 Prof. Jennifer Welch CSCE 668 Set 16: Distributed Shared Memory 1.
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Chapter 1 Logic and proofs
Introduction to probability (5)
Copyright © Cengage Learning. All rights reserved.
Information Technology Department
Equivalence Class Testing
Variables ICS2O.
Intro to Data Structures
Software testing.
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Computer Security: Art and Science, 2nd Edition
Presentation transcript:

Tracelets: a Model for the Laws of Concurrent Programming Tony Hoare OxfordFeb 2012

Our Universe E is a set of events that can occur in or around a computer during execution of a program – drawn as boxes. D is a set of dependencies between the events – drawn as arrows between boxes – e --> f means f depends on e source, target: D --> E source(d) --> target(d)

Labels P are sets of properties of D or E – e.g., the type of command executed – the objects involved in the event – the value of the data transmitted on the arrow labels:E + D --> P – labels(e) are drawn in the box, – labels(d) on top of the arrow

A tracelet is a subset of E, denoted by p, q, r. For example: a trace of a single execution of a program or of a single execution of a command or of a single object used in the execution I = { }, the tracelet that contains no event

An object is used by a program to store or transmit data – e.g., a variable, a semaphore, a channel, … Its behaviour is modelled by a tracelet – containing some or all events in which it has engaged A trace of a complete program execution – is the union of all the tracelets for every resource that it has used

Pictorially νδ ν labels the allocation of an object. δ labels its disposal. All other events of its tracelet lie in between

A variable νδ :=4labels an assignment of value 4 =4 labels a fetch of value 4 : =3 :=2 : =4 =4 =3 =2

Object names νxνxδxδx may be added to the labels x: =3 x:=2 x: =4 x= 4 x=3 x=2

A variable νδ The arrows from each fetch to the next assignment ensures prompt overwriting : =3 :=2 : =4 =4 =3 =2

Weak memory νδ … which does not occur in modern weak memories. : =3 :=2 : =4 =4 =3 =2

A Semaphore ν δ P is an acquisition of the semaphore V is a release (by the same owner) V P V P

A buffered channel ν δ !4labels an output of value 4 ?4 labels an input of value 4 ! =3 !2 !4!4 ?4 ?3 ?2

A single-buffered channel δ !3!3 !2 !4!4 ?4 ?3 ?2 Each output depends on prior input of the previous message ν

A complete program trace is the union of the tracelets for every command that it contains. The tracelet of a command can be analysed into sub-tracelets for each of its immediate sub-commands. The analysis determines whether the trace is a valid trace for the program.

Concurrent Composition p|q = p  q, provided that p  q = { } – otherwise the analysis is invalid, because no event is an execution of two distinct commands. Theorem: | is associative and commutative with unit 

Definitions p --> q =  e є p, f є q. e --> f p => q = p = q or p is undefined.

Sequential Composition p ; q= p|q provided not q --> p – otherwise the analysis is invalid, because no event in execution of the first command can depend on any event in the execution of the second. Theorem: ; is associative with unit 

Example x := 3 x := 4 If x is a shared variable x := 3 ; x:=4=

Or, x := 3 x := 4 if blue arrows are equal, x := 3 ; x:=4=

Theorems p;q => p|q – Proof: they are equal whenever not q --> p – otherwise, lhs is undefined (p|p’);q=> p|(p’;q) – they are equal when they are both defined – if rhs is undefined, then q --> p’ – which implies that q --> (p’|q), – therefore the lhs is also undefined.

Exchange laws p;(q|q’) => (p;q)|q’ – proof similar (p|p’);(q|q’) => (p;q)|(p’;q’) – proof similar All exchange laws are derivable from the last, – by substituting  for p’, or q’, – or for both q and q’

Separating concurrency? r = p||q=r = p;q & r = q;p – there is no arrow between p and q BUT – this would prohibit shared variables – p||q <p;q – p ; (q||q’)< (p;q)||q’etc. – the wrong way round! Let’s postpone this problem

A command is modelled by the set of tracelets of all its possible executions in all its possible environments.  = { { } } x := 3 = { p | ‘x :=3’ є labels(p)} x := y = { p |  n. {‘x:= n’, ‘y = n’}  labels(p)}

Let P, Q, R, be commands P | Q = { (p|q)| p є P & q є Q } P ; Q = { (p;q) | p є P & q є Q } P \/ Q = { r | r є P or r є Q } P  Q =  r. r є P => r є Q All our theorems p => q also hold for P  Q, – because every variable appears exactly once on each side of the inequation.

Separation Let L be the set of red arrows – they must not cross thread boundaries Blue arrows must cross thread boundaries Black arrows may cross either boundaries. Definitions of ; and | must be changed to ensure these rules

Dependency ordering Let e < f mean that there is a path of arrows from e to f. e <L f means the path consists of red arrows p f, for some e є p, f є q

Interfaces of a tracelet p arrows(p) = s(p) u t(p) ins(p) =t(p) - s(p) outs(p) =s(p) - t(p) – where s(p) = {d| source(d) є p} t(p) = {d| target(d) є p}

In pictures… outs ins

Separating ; p;q= p|q provided that not q < p & outs(p)  L = ins(q)  L – outs(p;q)  L = outs(q)  L – ins(p;q)  L = ins(p)  L Theorem: ; is associative and has unit 

Ok is a set of tracelets that are always preferred – e.g., no overflow, no races, no divergence, etc. p => qmeansp = q orp is not defined ornot q є ok  є ok p;q є ok=p є ok & q є ok

Separating concurrency e < f= there is a path of red dependencies from e to f p*q є ok=p є ok & q є ok &not p < q & not q < p p*q = p|qif p*q є ok – because that’s the way it will be implemented!

Lift to sets P => Q means  p є P. p є ok => p є Q otherwise  q є Q. not q є ok & ins(q) = ins(p)