Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek
Model Shared memory model.Shared memory model. Wait-free linearizable algorithms.Wait-free linearizable algorithms.
Computability
Computability Snapshot implementation from read-write registers. Snapshot implementation from read-write registers.Stack? X implementation from stacks and read-write registers? X implementation from stacks and read-write registers?
Wait-free hierarchy Consensus number 1 2 … [Herlihy 91] Object’s consensus number: Maximum number of processes that can implement consensus using copies of the object and R/W registers. R/W registers.
Wait-free hierarchy Consensus number 1 2 … Stack Register [Herlihy 91]
Wait-free hierarchy Consensus number 1 2 … Stack F&A Swap Queue Register [Herlihy 91] swap(x): old := v v := x return old F&A(x): old := v v += x return old
Queue Wait-free hierarchy Consensus number 1 2 … Stack F&A Swap Register [Herlihy 91] More than 2 processes? Common2
Queue This talk Consensus number 1 2 … Stack F&A Swap Register Common2
Stack algorithm 0 r cells Ø Ø Ø Ø Ø Ø Ø
Pop() {Push(x) { for t:=F&A(r,0)-1 t := F&A(r,1) for t:=F&A(r,0)-1 t := F&A(r,1) downto 0 { cells[t] := x downto 0 { cells[t] := x x := swap(cells[t], Ø)} x := swap(cells[t], Ø)} if (x != Ø( return x if (x != Ø( return x } return EMPTY return EMPTY{ Stack algorithm 0 r cells Push(x) 1 x Push(y) 2 Pop Swap Swap Ø Ø Ø Ø Ø Ø Ø Wait-free
Linearizability proof
Concurrent matching Push/Pop pairs can be ignored.Concurrent matching Push/Pop pairs can be ignored. Obtain an execution where Pop starts after corresponding Push has finished. Push(x)Push(y) Pop: y Push(z) Pop: z
Linearizability proof Linearizability: assign each operation a linearization point at some event during its execution. Handling ties: build explicit sequential order to breaks ties.
Linearizing procedure that processes the execution, using an auxiliary array, and outputs a linearization. Proof technique aux
Auxiliary array aux x Lin=Push(y) Pop:y Push(x)
Push is linearized when it writes: If to top of array, linearized now. Else, with the Push above it. Linearizing Push() aux x zPush(z) Lin=Push(y) Pop:y Push(x) Push(w) w Lin=Push(y) Pop:y Push(w) Push(x) Push(z)
Pops are linearized as soon as their return value is at top of the auxiliary array. Linearizing Pop() cells x z w Lin=Push(y) Pop:y Push(w) Push(x) Push(z) Pop:xPop:z Pop:x x z w Pop:x aux Pop:z Pop:zEMPTY
Linearization proc correctness Linearization is a valid stack execution.Linearization is a valid stack execution. Linearization respects real-time order.Linearization respects real-time order.
Push is linearized when it writes: If to top of array, linearized now. Else, with the Push above it. Linearizing Push() aux x zPush(z) Push(w) w Push(w) Push(x) F&A F&Awrite write
Linearization proc correctness Linearization is a valid stack execution.Linearization is a valid stack execution. Linearization respects real-time order.Linearization respects real-time order. Every operation is linearized.Every operation is linearized.
Pops are linearized as soon as their return value is at top of the auxiliary array. Every Pop() is linearized cells x z Pop:x x z Pop:x aux Pop:z ww Pop:x – first to finish without being linearized
Linearization proc correctness Linearization is a valid stack execution.Linearization is a valid stack execution. Linearization respects real-time order.Linearization respects real-time order. Every operation is linearized.Every operation is linearized.
Queue Conclusion Consensus number 1 2 … Stack F&A Swap Register Common2 ?