240 likes | 391 Views
This work explores advancements in wait-free linearizable algorithms within shared memory models. It reviews the consensus number of objects, including stacks and registers, and presents a detailed implementation of snapshot algorithms using read-write registers. The methodology is based on the wait-free hierarchy established by Herlihy in 1991, emphasizing the linearizability of operations like push and pop in concurrent settings. Various proofs of linearization correctness and the treatment of ties during operations are also discussed, providing insights essential for designing efficient concurrent data structures.
E N D
Common2 Extendedto Stacks Adam Morrison joint with Yehuda Afek Eli Gafni
Model • Shared memory model. • Wait-free linearizable algorithms.
Stack ? Computability Snapshot implementationfrom read-write registers. X implementationfrom stacks and read-write registers?
Wait-free hierarchy [Herlihy 91] Object’s consensus number: Maximum number of processes that can implement consensus using copies of the object and R/W registers. … Consensusnumber 2 1
Wait-free hierarchy [Herlihy 91] … Consensusnumber 2 Stack Register 1
Wait-free hierarchy [Herlihy 91] F&A(x): old := v v += x return old swap(x): old := v v := x return old … F&A Consensusnumber Swap 2 Queue Stack Register 1
Wait-free hierarchy [Herlihy 91] Common2 … More than 2 processes? F&A Consensusnumber Swap 2 Queue Stack Register 1
This talk Common2 … F&A Consensusnumber Swap 2 Queue Stack Register 1
Stack algorithm Ø Ø Ø Ø Ø Ø Ø cells r 0
Swap Swap Stack algorithm Pop() { Push(x) { for t:=F&A(r,0)-1 t := F&A(r,1) downto 0 { cells[t] := x x := swap(cells[t], Ø) } if (x != Ø( return x } return EMPTY { Ø Wait-free Ø Ø Ø Ø Ø x Ø cells r Push(x) 1 2 0 Pop Push(y)
Linearizability proof • 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.
Proof technique Linearizing procedure that processes the execution, using an auxiliary array, and outputs a linearization. aux
Auxiliary array Lin=Push(y) Pop:y Push(x) x aux
Linearizing Push() Push is linearized when it writes: If to top of array, linearized now. Else, with the Push above it. Push(z) z Lin=Push(y) Pop:y Push(x) Lin=Push(y) Pop:yPush(w)Push(x)Push(z) x Push(w) w aux
EMPTY Linearizing Pop() Pops are linearized as soon as their return value is at top of the auxiliary array. Lin=Push(y) Pop:y Push(w) Push(x) Push(z) Pop:z Pop:x Pop:x Pop:z Pop:x Pop:z z z x x w w cells aux
Linearization proc correctness • Linearization is a valid stack execution. • Linearization respects real-time order.
Linearizing Push() Push is linearized when it writes: If to top of array, linearized now. Else, with the Push above it. Push(z) z F&A write Push(x) x F&A write Push(w) w Push(w) aux
Linearization proc correctness • Linearization is a valid stack execution. • Linearization respects real-time order. • Every operation is linearized.
Every Pop() is linearized Pops are linearized as soon as their return value is at top of the auxiliary array. Pop:x Pop:x Pop:z z z w w x x cells aux Pop:x – first to finish without being linearized
Linearization proc correctness • Linearization is a valid stack execution. • Linearization respects real-time order. • Every operation is linearized.
Conclusion Common2 … F&A Consensusnumber Swap ? 2 Queue Stack Register 1