680 likes | 858 Views
David Kitchin. Atomicity and Structured Concurrency. The University of Texas at Austin. The Orc programming language Adding transactions to Orc Traceless semantics Atomic choice. Overview. A structured concurrent programming language Based on a simple calculus with four combinators
E N D
David Kitchin Atomicity and Structured Concurrency The University of Texas at Austin
The Orc programming language Adding transactions to Orc Traceless semantics Atomic choice Overview
A structured concurrent programming language Based on a simple calculus with four combinators See for yourself: http://orc.csres.utexas.edu/ What is Orc?
SITES + - * / Ref Channel if Rwait ( , ) [ , , ] Google
PARALLEL F | G SITES + - * / Ref Channel if Rwait ( , ) [ , , ] Google
PARALLEL SEQUENTIAL F >x> G F | G SITES + - * / Ref Channel if Rwait ( , ) [ , , ] Google
PARALLEL SEQUENTIAL F >x> G F | G SITES + - * / Ref Channel if Rwait ( , ) [ , , ] Google PRUNING F <x< G val x = G F
PARALLEL SEQUENTIAL F >x> G F | G SITES + - * / Ref Channel if Rwait ( , ) [ , , ] Google PRUNING OTHERWISE F <x< G F ; G val x = G F
PARALLEL SEQUENTIAL F >x> G F | G SITES + - * / Ref Channel if Rwait ( , ) [ , , ] Google PRUNING OTHERWISE F <x< G F ; G FUNCTIONS val x = G F def f(x) = ...
Two essential differences in Orc: Parallelism is recursive and pervasive Services are shared and external Towards Transactions
ATOMIC atomic F
atomic F executes expression F within a transaction Two important observations: F could use any combinator (including atomic) F could call any site atomic
Sites must cooperate with Orc to maintain atomicity A very challenging mix of resources: TM with nested parallelism Objects with interesting semantics (channels, sets, etc) Web services, etc. I can’t solve all of these problems on my own; I am simply searching for a more uniform API to others’ solutions. Transactional Sites
Some sites are pure, ignoring transactions entirely (+, if, ...) Some sites are nontransactional (fire the missiles!) Some sites are transaction-only (a la Haskell STM) Some sites support only depth 1 (TxOS, etc) Some sites support nesting but not parallel nesting (MySQL) Static analysis may be able to reveal misuses of sites Taxonomy
Increment atomic ( ctr? >y> ctr := y+1 )
Swap def swap(x,y) = atomic ( (x?, y?) >(a,b)> (x := b, y := a) )
Rotation def rotate(x,y,z) = atomic ( swap(x,y) >> swap(y,z) )
The execution of F is transactional if the following two properties hold:
Consider a causal relation ≺ : Event × Event If x ≺ y (“x precedes y”), then any effects of x are seen by y ≺ is a strict partial order (antisymmetric and transitive)
Notation • a ≺ S ≡ ∀s ∈ S :: a ≺ s • S ≺ a ≡ ∀s ∈ S :: s ≺ a
A set of events E is transactional iff, for all e ∈ E and x ∉ E,
A set of events E is transactional iff, for all e ∈ E and x ∉ E, x ≺ e ⇒ x ≺ E and e ≺ x ⇒ E ≺ x
A set of events E is transactional iff, for all e ∈ E and x ∉ E, Isolation x ≺ e ⇒ x ≺ E Atomicity e ≺ x ⇒ E ≺ x
a b Notation • ≡ a≺b
x e E x≺e
x e E x≺e Isolation ⇒ x≺E
y e e ≺ y E
y e ≺ y E ⇒ e Atomicity E ≺ y
x y E
x y E
x y E
x y E
E E’
E E’
atomic ( • z := x • x := z+1 • ) • atomic ( • y := x • x := y+1 • )
z := x y := x x := z+1 x := y+1
z := x y := x x := z+1 x := y+1
z := x y := x x := z+1 x := y+1
y := x x := y+1
z := x y := x x := z+1 x := y+1
z := x y := x x := z+1 x := y+1
z := x x := z+1 y := x x := y+1 CYCLIC CAUSALITY
The π-calculus has guarded choice: a?(x).c!(x) + b?(x).c!(x) Can we do this in Orc?
Does this work? val x = a.get() | b.get() c.put(x)
val x = 3 | b.get() c.put(x)
val x = 3 | 4 c.put(x)