CS519: Lecture 10 z (Software) Distributed Shared Memory (aka Shared Virtual Memory)
1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory:...
-
Upload
barbara-jackson -
Category
Documents
-
view
218 -
download
0
Transcript of 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory:...
![Page 1: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/1.jpg)
1
Consensus HierarchyPart 1
![Page 2: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/2.jpg)
2
Consensus in Shared Memory
Consider processors in shared memory:n
10,..., npp
which try to solve the consensus problem
![Page 3: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/3.jpg)
3
0
1
0
0p
1p
2p
0
1
0
3p
4p
5p
Every process starts with an initial valuestored in local memory (0 or 1)
Shared memory
Local memory
Local memory
![Page 4: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/4.jpg)
4
0
1
0
0p
1p
2p
0
1
0
3p
4p
5p
communication through shared memory
![Page 5: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/5.jpg)
5
1
1
1
0p
1p
2p
1
1
1
3p
4p
5p
At the end of execution, every processhas decided the same value (0 or 1)
![Page 6: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/6.jpg)
6
Validity condition:
If every process starts with the same value, the every process should decide that value
Additional condition:The decided value is one of the initial values
![Page 7: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/7.jpg)
7
Wait-freedom in asynchronous systems:
A process should be able to finishexecution of an algorithmeven if all other processes fail
Wait-freedom captures:•Asynchronous executions•Crash failures
![Page 8: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/8.jpg)
8
Object Types
Read/Write
FIFO
Compare&Swap
Test&Set
n-register assignment
![Page 9: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/9.jpg)
9
Consensus Number
Consensus Number of an object type:
The maximum number of processes for which the object can be used tosolve the wait-free consensus problem(together with read/write objects)
![Page 10: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/10.jpg)
10
Object Type Consensus Number
Read/Write 1
FIFO, Test&Set 2
Compare&Swap (infinity)
n-register assignment 2n-2
![Page 11: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/11.jpg)
11
int compare_and_swap ( int* register, int oldval, int newval) { int old_reg_val = *register; if (old_reg_val == oldval) *register = newval; return old_reg_val;}
int Test-and-Set(boolean lock) { boolean initial = lock; lock = true; return initial;}
(Shared ) boolean lock = false;
function Critical_Section() { while TestAndSet(lock) skip //spin until lock is acquired //Critical-section code - only one process can be in this section at a time begin { … } //end-of critical section – release lock lock = false //release lock when finished with the critical section }
Mutual Exclusion
![Page 12: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/12.jpg)
12
Simulation:Object Type B
Object Type A
Object Type A
Read/Write Object
Object of type A simulates object of Type B(using auxiliary read/write objects)
![Page 13: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/13.jpg)
13
Theorem:Objects of Type A with consensus numbercannot simulate in wait-free manner another object of Type B withconsensus number
n
nm
Proof: Since otherwise, object A wouldhave consensus numberm
End of Proof
![Page 14: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/14.jpg)
14
can simulate in a wait-free mannerany other arbitrary object
Universal object:
Compare&SwapExample:
(infinity consensus number)
![Page 15: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/15.jpg)
15
Objects with consensus number ncan simulate in a wait-free mannerany other arbitrary object of up toprocessors
n
We can show:
![Page 16: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/16.jpg)
16
Read/Write
Shared Memory
Suppose that the sharedmemory can only be accessedthrough Read or Write operations
![Page 17: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/17.jpg)
17
Theorem:
Proof of Theorem:
The consensus number of the Read/Write object is 1
Trivially, any consensus algorithm with 1 process using read/write variables is wait-free.
![Page 18: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/18.jpg)
18
Wait-free consensus cannot besolved using only read/write objectsfor processors 2n
It remains to show:
We will show that any algorithmthat solves wait-free consensus for has an execution that never terminates
Approach:
2n
![Page 19: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/19.jpg)
19
System configuration:
Is the set of all variables in the system, including local and shared
0
1
0
0p
1p
2p
0
1
0
3p
4p
5p
C
![Page 20: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/20.jpg)
20
A distributed system execution can be always be viewed as a: sequence of configurations
0C fC1C 2C
Initialconfiguration
Finalconfiguration
0ip
1ip
2ip
Processor action: Read or Write
![Page 21: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/21.jpg)
21
1
C
D
C D
1 0 1 0 0 0
bivalent
univalentunivalent
bivalent
Valence of system configurations
1-valent0-valent
Consensus value at possible execution paths
consensus reached consensusnot reached
consensus reached
![Page 22: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/22.jpg)
22
A terminating execution:
0C 1C 2C
Initialconfiguration
0ip
1ip
2ip
Bivalent Bivalent Univalent
fC
Univalent
UnivalentBivalent
Finalconfiguration
![Page 23: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/23.jpg)
23
To prove the theorem, we will show that there is always an executionwhere every configuration is bivalent
0C 1C 2C
Initialconfiguration
0ip
1ip
2ip
Bivalent Bivalent Bivalent
Never-ending execution
Bivalent
![Page 24: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/24.jpg)
24
1
1
1
0p
1p
2p
1
0
0
0p
1p
2p
Similar configurations for processor 0p
23
198
76
23
198
76
Same shared variablesLocal variables of others may differ
1C 2C21
0
CCp
![Page 25: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/25.jpg)
25
21 CCip
Lemma:If there exist univalent configurations
1C and such that2C
then if is -valentthen is -valent too
1C
2Cv
v
Proof of Lemma:
)1 or 0( v
![Page 26: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/26.jpg)
26
1C
Univalent
Executionwith onlytaking actions
ip
ip
v v v
All possible executionsfrom 1C
final decision for each Possible execution
![Page 27: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/27.jpg)
27
1C
Univalent
Executionwith onlytaking actions
ip
ip
v v v
2C
Univalent
Executionwith onlytaking actions
ip
ip
x x x
![Page 28: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/28.jpg)
28
1C
Univalent
Executionwith onlytaking actions
ip
ip
v v v
2C
Univalent
Executionwith onlytaking actions
ip
ip
x vx x
21 CCip
![Page 29: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/29.jpg)
29
1C
Univalent
Executionwith onlytaking actions
ip
ip
v v v
2C
Univalent
Executionwith onlytaking actions
ip
ip
21 CCip
v v v
End of Lemma Proof
![Page 30: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/30.jpg)
30
Lemma:There exists a bivalentinitial configuration
Proof of Lemma:
![Page 31: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/31.jpg)
31
Possible Initial Configurations
Shared Memory
Empty
Local Memory
10p
Initial Configuration1I
11p
1np 1
0
0I
0
0
0
01I
1
1
![Page 32: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/32.jpg)
32
Possible Initial Configurations
Shared Memory
Empty
Local Memory
10p
11p
1np 1
0
0I
0
0
0
01I
1
1
0-valent 1-valent?
Initial Configuration1I
![Page 33: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/33.jpg)
33
Possible Initial Configurations
Shared Memory
Empty
Local Memory
10p
11p
1np 1
0
0I
0
0
0
01I
1
1
0-valent 1-valent1-valent?
No, because 010
0
IIp
Initial Configuration1I
![Page 34: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/34.jpg)
34
Possible Initial Configurations
Shared Memory
Empty
Local Memory
10p
11p
1np 1
0
0I
0
0
0
01I
1
1
0-valent 1-valent0-valent?
No, because 101
1
IIp
Initial Configuration1I
![Page 35: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/35.jpg)
35
Possible Initial Configurations
Shared Memory
Empty
Local Memory
10p
11p
1np 1
0
0I
0
0
0
01I
1
1
0-valent 1-valentbivalent
End of Lemma Proof
Initial Configuration1I
![Page 36: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/36.jpg)
36
Critical processor for a configuration:
the configuration is bivalent,and after the processor takes stepthe configuration becomes univalent
C C ipBivalent Univalent
![Page 37: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/37.jpg)
37
Lemma:If is a bivalent configurationthen, there is at least one processorwhich is not critical
C
Proof of Lemma:
![Page 38: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/38.jpg)
38
Assume for contradiction that all processors are critical
C
0C
1C
1nC
bivalent0p
1p
1np
univalent
univalent
univalent
Possibleexecutions
![Page 39: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/39.jpg)
39
C
bivalent0p
1p
1np
valent
It cannot be that all have the same valence
v
)1 or 0( v
valentv
valentv
0C
1C
1nC
![Page 40: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/40.jpg)
40
C
bivalent0p
1p
1np
valent
It cannot be that all have the same valence
v
)1 or 0( v
valentv
valentv
valentv
Contradiction 0C
1C
1nC
![Page 41: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/41.jpg)
41
C
bivalent0p
jp
1np
There must exist two processors with different valences
iC
jC
ip
0C
1nC
valent-0
valent-1
![Page 42: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/42.jpg)
42
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Case 1: suppose that they access different shared variables
Read x
Read y
x
y
ip
jp
![Page 43: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/43.jpg)
43
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Read x
Read y
two possible executions
C
C
jp
ip
Read y
Read x
valent-0
valent-1
impossible since CC different valence
![Page 44: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/44.jpg)
44
same result holds for any kind of operation (Read or Write) that the processors apply to x and y
![Page 45: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/45.jpg)
45
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Case 2: suppose that they access the same shared variable
Read x
Read x
xip
jp
subcase: read/read
![Page 46: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/46.jpg)
46
two possible executions
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Read x
Read x
C
C
jp
ip
Read x
Read x
valent-0
valent-1
impossible since CC different valence
![Page 47: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/47.jpg)
47
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Read x
Write x
subcase: read/write
![Page 48: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/48.jpg)
48
two possible executions
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Read x
Write x
C
C
jp
ip
Write x
Read x
valent-0
valent-1
impossible since j
p
CCj
different valence
![Page 49: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/49.jpg)
49
subcase: write/write
C
bivalent
jp
iC
jC
ip
valent-0
valent-1
Write x
Write x
C
C
jp
ip
Write x
Write x
valent-0
valent-1
impossible since j
p
CCj
different valence
![Page 50: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/50.jpg)
50
In all cases we obtained contradictionTherefore, there exists a processorwhich is not critical
C
0C
1C
1nC
bivalent0p
1p
1np
univalent
univalent
univalent
kC bivalent(not critical)
End of Lemma Proof
![Page 51: 1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.](https://reader035.fdocuments.us/reader035/viewer/2022062804/56649f215503460f94c3964c/html5/thumbnails/51.jpg)
51
Therefore, we can construct an execution
0C 1C 2C
Initialconfiguration
0ip
1ip
2ip Never
ends
bivalent bivalent bivalent
Consensus can never be reached
End of Theorem Proof