Top Banner
Common2 Extended Common2 Extended to Stacks to Stacks Adam Morrison Adam Morrison joint with joint with Eli Gafni Eli Gafni Yehuda Afek Yehuda Afek
24

Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Dec 18, 2015

Download

Documents

Joel Washington
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Common2 ExtendedCommon2 Extendedto Stacksto Stacks

Adam MorrisonAdam Morrisonjoint withjoint with

Eli GafniEli GafniYehuda AfekYehuda Afek

Page 2: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

ModelModel

• Shared memoryShared memory model. model.

• Wait-free linearizable Wait-free linearizable algorithms. algorithms.

Page 3: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

ComputabilityComputability

Page 4: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

ComputabilityComputability

Snapshot Snapshot implementationimplementation fromfrom read-write registersread-write registers..

StackStack??

X X implementationimplementation fromfrom stacks stacks and and read-write registersread-write registers??

Page 5: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Wait-free hierarchyWait-free hierarchyCo

nsen

sus

Cons

ensu

s num

ber

num

ber

11

22

[[Herlihy 91Herlihy 91]]

Object’s Object’s consensus numberconsensus number::Maximum number of Maximum number of processes that can processes that can implement consensus usingimplement consensus usingcopies of the object andcopies of the object and R/W registers.R/W registers.

Page 6: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Wait-free hierarchyWait-free hierarchyCo

nsen

sus

Cons

ensu

s num

ber

num

ber

11

22

Stack

Register

[[Herlihy 91Herlihy 91]]

Page 7: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Wait-free hierarchyWait-free hierarchyCo

nsen

sus

Cons

ensu

s num

ber

num

ber

11

22

Stack

F&A SwapQueue

Register

[[Herlihy 91Herlihy 91]]

swap(x):swap(x):

old := old := vv

vv := x := x

returnreturn old old

F&A(x):F&A(x):

old := old := vv

vv += x += x

returnreturn old old

Page 8: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Queue

Wait-free hierarchyWait-free hierarchyCo

nsen

sus

Cons

ensu

s num

ber

num

ber

11

22

Stack

F&A Swap

Register

[[Herlihy 91Herlihy 91]]

More than 2 processes?More than 2 processes?

Common2Common2

Page 9: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Queue

This talkThis talkCo

nsen

sus

Cons

ensu

s num

ber

num

ber

11

22

Stack

F&A Swap

Register

Common2Common2

Page 10: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Stack algorithmStack algorithm

0

rr

cellscells

ØØ

ØØ

ØØ

ØØ

ØØ

ØØ

ØØ

Page 11: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Pop() {Pop() { Push(x) {Push(x) {

for t:=F&A(r,0)-1for t:=F&A(r,0)-1 t := F&A(r,1) t := F&A(r,1)

downto 0 {downto 0 { cells]t[ := x cells]t[ := x

x := swap(cells]t[, Ø)x := swap(cells]t[, Ø) }}

if (x != Øif (x != Ø(( return x return x

}}

return EMPTYreturn EMPTY

{{

Stack algorithmStack algorithm

0

rr

cellscells

Push(x)Push(x)1

x

Push(y)Push(y)

2

PopPop

SwapSwap

SwapSwap

ØØ

ØØ

ØØ

ØØ

ØØ

ØØ

ØØ

Wait-free

Wait-free

Page 12: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearizability proofLinearizability proof

Page 13: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearizability proofLinearizability proof• Concurrent matching Push/Pop pairs can Concurrent matching Push/Pop pairs can

be ignored.be ignored.

Obtain an execution where Pop starts after Obtain an execution where Pop starts after corresponding Push has finished.corresponding Push has finished.

Push(x)Push(x) Push(y)Push(y) Pop: yPop: y

Push(z)Push(z)

Pop: zPop: z

Page 14: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearizability proofLinearizability proofLinearizability: Linearizability: assign each assign each

operation a linearization point at operation a linearization point at some some eventevent during its execution. during its execution.

Handling tiesHandling ties: build explicit : build explicit sequential order to breaks ties.sequential order to breaks ties.

Page 15: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearizing procedure thatLinearizing procedure thatprocesses the execution,processes the execution,using an using an auxiliary arrayauxiliary array,,and outputs aand outputs alinearization.linearization.

Proof techniqueProof technique

auxaux

Page 16: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Auxiliary arrayAuxiliary array

auxaux

xLin=Push(y) Pop:y Push(x)Lin=Push(y) Pop:y Push(x)

Page 17: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Push is linearized when it writes:Push is linearized when it writes:If to top of array, linearized now.If to top of array, linearized now.Else, with the PushElse, with the Pushabove it.above it.

Linearizing PushLinearizing Push()()

auxaux

x

zPush(z)Push(z)

Lin=Push(y) Pop:y Push(x)Lin=Push(y) Pop:y Push(x)

Push(w)Push(w) w

Lin=Push(y) Pop:yLin=Push(y) Pop:y Push(w)Push(w) Push(x)Push(x) Push(z)Push(z)

Page 18: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Pops are linearized as soon as their returnPops are linearized as soon as their returnvalue is at top value is at top of the auxiliary arrayof the auxiliary array..

Linearizing PopLinearizing Pop()()

cellscells

xx

zz

w

Lin=Push(y) Pop:y Push(w) Push(x) Push(z)Lin=Push(y) Pop:y Push(w) Push(x) Push(z)

Pop:xPop:x Pop:zPop:z

Pop:xPop:x

xx

zz

ww

Pop:xPop:x

auxaux

Pop:zPop:z

Pop:zPop:z

EMPTYEMPTY

Page 19: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearization proc correctnessLinearization proc correctness•Linearization is a valid stack Linearization is a valid stack

execution. execution. •Linearization respects real-time Linearization respects real-time

order.order.

Page 20: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Push is linearized when it writes:Push is linearized when it writes:If to top of array, linearized now.If to top of array, linearized now.Else, with the PushElse, with the Pushabove it.above it.

Linearizing PushLinearizing Push()()

auxaux

x

zPush(z)Push(z)

Push(w)Push(w) w

Push(w)Push(w)

Push(x)Push(x)

F&AF&A

F&AF&A writewrite

writewrite

Page 21: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearization proc correctnessLinearization proc correctness•Linearization is a valid stack Linearization is a valid stack

execution. execution. •Linearization respects real-time Linearization respects real-time

order.order.•Every operation is linearized.Every operation is linearized.

Page 22: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Pops are linearized as soon as their returnPops are linearized as soon as their returnvalue is at top of the auxiliary array.value is at top of the auxiliary array.

Every Pop() is linearizedEvery Pop() is linearized

cellscells

xx

zzPop:xPop:x

xx

zz

Pop:xPop:x

auxaux

Pop:zPop:z

ww ww

Pop:x – first to finish without being linearizedPop:x – first to finish without being linearized

Page 23: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Linearization proc correctnessLinearization proc correctness•Linearization is a valid stack Linearization is a valid stack

execution. execution. •Linearization respects real-time Linearization respects real-time

order.order.•Every operation is linearized.Every operation is linearized.

Page 24: Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.

Queue

ConclusionConclusionCo

nsen

sus

Cons

ensu

s num

ber

num

ber

11

22

Stack

F&A Swap

Register

Common2Common2

??