YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Unifying Theories Execution History

Tony Hoare

In honour of Manfred Broy30 October 2009

Page 2: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.
Page 3: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Manfred Broy and Tony Hoare at Marktoberdorf.

Page 4: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Unifying…

• Memory– shared/private, weakly/strongly consistent

• Communication– synchronised/buffered, reliable/unreliable

• Resource management– dynamic/nested, disposed/collected

Page 5: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Unifying…

• Sequential programming– C, Java, C#, ...

• Process algebras and calculi– stream processing functions– CCS, CSP, pi

• Shared memory, threads– fine-grained, coarse-grained, transactions– weakly consistent memory

Page 6: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Labelled graphs

• Trace semantics (Mazurkiewicz)• Regular expressions (Kleene)• Causal nets (Petri)• Event structure configurations (Winskel)• Message Sequence Charts (UML)

INSIGHT! They are all labeled graphs

Page 7: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A labeled Graph

• E: a set of nodes (events)• A: a set of arrows (denoting data flow)• L: a set of labels (to be determined)• source, target: A -> E• label: A -> L (labelling the arrow)• label: E -> L (labelling the events)

Page 8: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Program Execution is recorded as a trace of• all events that have occurred– drawn as boxes

• all dependencies between them– drawn as arrows

source target– the target could not occur before source

Page 9: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Program Execution is recorded as a trace of:• all events that have occurred– drawn as boxes– with labels naming the executed command

• all dependencies between them– drawn as arrows

source target– with labels naming resource.value, etc.

x := 3

x.3x := 3 x = 3

Page 10: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A Sequential Resource

begin endnextnextnext next

Page 11: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Implementation

begin endnextnextnext next

•allocated globally/on stack/in heap/…

•disposed from stack/by command/by collector/by OS

Page 12: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Fork

fanout

all arrows of the graphhave the same source

Page 13: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Join

fanin

all arrows of the graph have the same target

Page 14: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Shared Resource

faninfanout

begin end

Page 15: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Publication

faninfanout

publish publish next

Page 16: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Assignment

faninfanout

:= 3 := 7next

=3

=3

=3

Page 17: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 18: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 19: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 20: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 21: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 22: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 23: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

A variable

begin end

nextnextnext next:= := :=

fanin faninfanoutfanout =

=

= =

Page 24: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Unassigned fetch

begin end

nextnextnext next:= := :=

fanin

fanin

fanout fanout faninfanout

Page 25: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Communication

! ! !

? ? ?

send send send

Page 26: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Ordering

nextnext

nextnext

! ! !

? ? ?

send send send

Page 27: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Channel

nextnextnext

nextnextnext

! ! !

? ? ?

endbegin

next

next

send send send

Page 28: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Single-buffered Channel

nextnextnext

nextnextnext

! ! !

? ? ?

endbegin

next

nextsend send send

sync sync

Page 29: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Synchronised

nextnextnext

nextnextnext

! ! !

? ? ?

endbegin

next

nextsend send send

sync sync sync

Page 30: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Lossy channel

nextnext

next

! ! !

? ?

send send

Page 31: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Stuttering channel

next

nextnext

! !

? ? ?

send send send

Page 32: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Fraudulent channel

next

nextnext

! !

? ? ?

send send

Page 33: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Overtaking

next

next

! !

? ?

sendsend

Page 34: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Reliable channel

• reliable = loss & fraud & stutter & merge & overtaking

Page 35: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Threads

forkbegin endnextnextnext next

beginnextnext

joinbeginnextnextnext next

end

fork

join

Page 36: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

An Atomic Assignment

x := x + y

x = 3

y= 4

x := 7

Page 37: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

An Atomic Assignment

x := x + y

x = 3

y= 4

x := 7

x.fanout.3 x.fanin

y.fanout.4 y.fanin

x.next x.next

x.fanout.7x.fanin

t.next t.next

Page 38: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

An Atomic Assignment

x := x + y

x = 3

y= 4

x := 7

x.fanout.3 x.fanin

y.fanout.4 y.fanin

x.next x.next

x.fanout.7x.fanin

t.next t.next

Page 39: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Events and atomic actions

• Each occurrence of an event in the trace of program execution belongs to the trace of exactly one resource (thread, variable, channel,…)

• Atomic actions are groups of synchronised events, including exactly one from the thread which invoked the action, and one (or more) from every resource used by it.

Page 40: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

v.fanout

v:= 4

v := 3 v:= 6

v.next

v.faninv.fanout

v.fanin

=3 = 4 = 6

v.next

v.next

v.next

A variable (fully labelled)

v.fanout

Page 41: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

t.nextt.next

v:= 4

v := 3 v:= 6 thread t

interfering thread

v.next

=3 = 4 = 6

v.next

v.next

A shared variable

v.next

Page 42: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Weakly consistent memory

as implemented in multi-core architecture,is even more complicated to define… and more still to use!

A common architecture is TSO

Page 43: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Total Store Ordering

:=4

sync

:=3 :=6 global memory

sync

Page 44: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Local memory

nextnext

val

next

:=4

sync

:=3 :=6

:= 4:= 3 := 6 local memory

global memory

sync

Page 45: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Local memory access

nextnext

val

next

:=4

sync

:=3 :=6

:= 4:= 3 := 6 local memory

global memory

= 3 = 4 = 6local memory

sync

Page 46: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

nextnext

val

next

:=4

sync

:=3 :=6

:= 4:= 3 := 6 local memory

global memory

other thread:=4

= 3 = 4 = 6local memory

sync

sync

:=3

Page 47: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Memory Barrier

nextnext

val

next

sync

:=4 :=3 :=6

:= 4:= 3 := 6 bar localmemory

globalmemory

Page 48: Unifying Theories Execution History Tony Hoare In honour of Manfred Broy 30 October 2009.

Summary

• Dependency and data flow are a primitive concepts adequate to describe the dynamic behaviour of many kinds of computing resource

• Labelled graphs provide a general frameworkadequate for a unifying theory of dependency


Related Documents