Title: Consensus Hierarchy Part 2
1Consensus HierarchyPart 2
2FIFO (Queue)
head
tail
FIFO Object
3Special case empty queue
tail
head
4A Wait-Free Consensus algorithm for 2 processors
using a FIFO object
tail
head
Initially
5Shared Memory
Queue
tail
head
Other Variables
6Local variables
initial values for the consensus problem
resulting values for the consensus problem
7Shared Memory
Queue
tail
head
Other Variables
Initial values
8Code for processor
//am I the first?
If then else
//yes, choose my value
//no, choose the other processors value
Note the algorithm uses a FIFO object
and read/write objects
9Example execution
Shared Memory
Queue
tail
head
10Suppose that accesses first the queue
Shared Memory
decides on its own value
Queue
tail
head
11Suppose that accesses second
Shared Memory
Queue
Consensus Reached
tail
head
decides on the other processors value
12Theorem
There is no wait-free consensus algorithm using
only FIFO objects and read-write objects for
Proof of Theorem
Consider three processors (the same proof
generalizes to more)
13There is a bivalent initial configuration (we
proved it before)
We will show that every bivalent
configuration has a processor which is not
critical
Therefore, we can construct an infinite execution
with bivalent configurations where consensus is
never reached
14Assume for contradiction that all processors are
critical
univalent
bivalent
Possible executions
univalent
univalent
15It cannot be that all have the same valence
Contradiction
valent
bivalent
valent
valent
valent
16There must exist two processors with different
valences
bivalent
univalent
17Shared Memory
Queue
Queue
Queue
Read/Write Objects
18Shared Memory
Case the processors access different
objects
Queue
Queue
bivalent
Queue
Read/Write Objects
univalent
Note if an object was read/write the analysis is
the similar
19Two possible executions
op Q2
op Q1
bivalent
op Q2
op Q1
Impossible since
univalent
20Shared Memory
Case the processors access same object
Queue
Queue
bivalent
Queue
Read/Write Objects
univalent
Note if the object was read/write the
analysis is the same as in the case with
read/write objects
21Subcase deq/deq
deq(Q)
bivalent
deq(Q)
univalent
22Queue Q before operations
deq(Q)
deq(Q)
bivalent
deq(Q)
deq(Q)
Impossible since
univalent
23Subcase deq/enq
deq(Q)
bivalent
enq(Q,x)
univalent
24Suppose Q was not empty
enq(Q,x)
deq(Q)
bivalent
enq(Q,x)
deq(Q)
Impossible since
univalent
25Suppose Q was empty
enq(Q,x)
deq(Q)
bivalent
enq(Q,x)
Impossible since
univalent
26Subcase enq/enq
enq(Q,a)
bivalent
enq(Q,b)
univalent
27Suppose Q was not empty
enq(Q,b)
enq(Q,a)
bivalent
enq(Q,b)
enq(Q,a)
univalent
28enq(Q,b)
Dequeue a
Dequeue b
enq(Q,a)
bivalent
enq(Q,b)
enq(Q,a)
Dequeue b
Dequeue a
univalent
Impossible since
29Explanation
decides
enq(Q,b)
enq(Q,a)
Suppose does not dequeue a
bivalent
A decision will be reached since the consensus
algorithm is wait-free
30decides
enq(Q,b)
enq(Q,a)
contradiction
bivalent
decides
enq(Q,b)
enq(Q,a)
The same value will be decided by , since
sees the same shared memory values in both
executions
31In all cases we obtained contradiction
Therefore, there exists a processor which is not
critical
univalent
bivalent
univalent
bivalent
(not critical)
univalent
32Therefore, we can construct an execution
bivalent
bivalent
bivalent
Never ends
Initial configuration
Consensus can never be reached
End of Theorem Proof
33CompareSwap
Shared Memory
CompareSwap(X,A,B)
Temp X If XA then X B Return Temp
X
34A Wait-Free Consensus algorithm for n processors
using a compareswap object
Local Memory
Shared Memory
First
Initial value
compareswap object
Final value
35Code for processor
If then else
//am I the first?
//yes, choose my value
//no, choose the value of the first which
is stored in First
Note the algorithm uses a compareswap
and read/write objects
36Example execution
Local Memory
Shared Memory
First
37Suppose executes first
Local Memory
Shared Memory
First
CompareSwap(First, ,0)
38Suppose executes first
Local Memory
Shared Memory
First
Realizes it is first, decides on its own value
39Suppose executes second
Local Memory
Shared Memory
CompareSwap(First, ,1)
First
40Suppose executes second
Local Memory
Shared Memory
First
Realizes is not first, decides on value of First
41Similarly for
Consensus has been reached
Local Memory
Shared Memory
First
Realizes is not first, decides on value of First
42The algorithm is wait-free, since after the
completion of the CompareSwap operation, every
processor decides (without considering whether
the other processors decide)