Consensus Hierarchy Part 1 1 Consensus in Shared

  • Slides: 51
Download presentation
Consensus Hierarchy Part 1 1

Consensus Hierarchy Part 1 1

Consensus in Shared Memory Consider processors in shared memory: which try to solve the

Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem 2

Local memory Shared memory Local memory Every process starts with an initial value stored

Local memory Shared memory Local memory Every process starts with an initial value stored in local memory (0 or 1) 3

communication through shared memory 4

communication through shared memory 4

At the end of execution, every process has decided the same value (0 or

At the end of execution, every process has decided the same value (0 or 1) 5

Validity condition: If every process starts with the same value, the every process should

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 6

Wait-freedom in asynchronous systems: A process should be able to finish execution of an

Wait-freedom in asynchronous systems: A process should be able to finish execution of an algorithm even if all other processes fail Wait-freedom captures: • Asynchronous executions • Crash failures 7

Object Types Read/Write FIFO Test&Set n-register assignment Compare&Swap 8

Object Types Read/Write FIFO Test&Set n-register assignment Compare&Swap 8

Consensus Number of an object type: The maximum number of processes for which the

Consensus Number of an object type: The maximum number of processes for which the object can be used to solve the wait-free consensus problem (together with read/write objects) 9

Object Type Consensus Number Read/Write 1 FIFO, Test&Set 2 n-register assignment 2 n-2 Compare&Swap

Object Type Consensus Number Read/Write 1 FIFO, Test&Set 2 n-register assignment 2 n-2 Compare&Swap (infinity) 10

int Test-and-Set(boolean lock) { boolean initial = lock; lock = true; return initial; }

int Test-and-Set(boolean lock) { boolean initial = lock; lock = true; return initial; } 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; } Mutual Exclusion (Shared ) boolean lock = false; function Critical_Section() { while Test. And. Set(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 = false //release lock when finished with the critical section } 11

Simulation: Object Type B Object Type A Read/Write Object of type A simulates object

Simulation: Object Type B Object Type A Read/Write Object of type A simulates object of Type B (using auxiliary read/write objects) 12

Theorem: Objects of Type A with consensus number cannot simulate in wait-free manner another

Theorem: Objects of Type A with consensus number cannot simulate in wait-free manner another object of Type B with consensus number Proof: Since otherwise, object A would have consensus number End of Proof 13

Universal object: can simulate in a wait-free manner any other arbitrary object Example: Compare&Swap

Universal object: can simulate in a wait-free manner any other arbitrary object Example: Compare&Swap (infinity consensus number) 14

We can show: Objects with consensus number can simulate in a wait-free manner any

We can show: Objects with consensus number can simulate in a wait-free manner any other arbitrary object of up to processors 15

Read/Write Shared Memory Suppose that the shared memory can only be accessed through Read

Read/Write Shared Memory Suppose that the shared memory can only be accessed through Read or Write operations 16

Theorem: The consensus number of the Read/Write object is 1 Proof of Theorem: Trivially,

Theorem: The consensus number of the Read/Write object is 1 Proof of Theorem: Trivially, any consensus algorithm with 1 process using read/write variables is wait-free. 17

It remains to show: Wait-free consensus cannot be solved using only read/write objects for

It remains to show: Wait-free consensus cannot be solved using only read/write objects for processors Approach: We will show that any algorithm that solves wait-free consensus for has an execution that never terminates 18

System configuration: Is the set of all variables in the system, including local and

System configuration: Is the set of all variables in the system, including local and shared 19

A distributed system execution can be always be viewed as a: sequence of configurations

A distributed system execution can be always be viewed as a: sequence of configurations Initial configuration Final configuration Processor action: Read or Write 20

Valence of system configurations bivalent univalent bivalent 1 -valent consensus reached consensus not reached

Valence of system configurations bivalent univalent bivalent 1 -valent consensus reached consensus not reached univalent 0 -valent consensus reached Consensus value at possible execution paths 21

A terminating execution: Final configuration Initial configuration Bivalent Univalent 22

A terminating execution: Final configuration Initial configuration Bivalent Univalent 22

To prove theorem, we will show that there is always an execution where every

To prove theorem, we will show that there is always an execution where every configuration is bivalent Initial configuration Bivalent Never-ending execution 23

Similar configurations for processor Same shared variables Local variables of others may differ 24

Similar configurations for processor Same shared variables Local variables of others may differ 24

Lemma: If there exist univalent configurations and such that then if then is is

Lemma: If there exist univalent configurations and such that then if then is is -valent too Proof of Lemma: 25

Univalent All possible executions from Execution with only taking actions final decision for each

Univalent All possible executions from Execution with only taking actions final decision for each Possible execution 26

Univalent Execution with only taking actions 27

Univalent Execution with only taking actions 27

Univalent Execution with only taking actions 28

Univalent Execution with only taking actions 28

Univalent Execution with only taking actions End of Lemma Proof 29

Univalent Execution with only taking actions End of Lemma Proof 29

Lemma: There exists a bivalent initial configuration Proof of Lemma: 30

Lemma: There exists a bivalent initial configuration Proof of Lemma: 30

Shared Memory Possible Initial Configurations Local Memory Initial Configuration Empty 31

Shared Memory Possible Initial Configurations Local Memory Initial Configuration Empty 31

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent ? 1

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent ? 1 -valent 32

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent No, because

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent No, because 1 -valent? 1 -valent 33

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent? 1 -valent

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent? 1 -valent No, because 34

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent bivalent 1

Shared Memory Empty Possible Initial Configurations Local Memory Initial Configuration 0 -valent bivalent 1 -valent End of Lemma Proof 35

Critical processor for a configuration: the configuration is bivalent, and after the processor takes

Critical processor for a configuration: the configuration is bivalent, and after the processor takes step the configuration becomes univalent Bivalent Univalent 36

Lemma: If is a bivalent configuration then, there is at least one processor which

Lemma: If is a bivalent configuration then, there is at least one processor which is not critical Proof of Lemma: 37

Assume for contradiction that all processors are critical univalent bivalent univalent Possible executions univalent

Assume for contradiction that all processors are critical univalent bivalent univalent Possible executions univalent 38

It cannot be that all have the same valence valent bivalent 39

It cannot be that all have the same valence valent bivalent 39

It cannot be that all have the same valence Contradiction bivalent valent 40

It cannot be that all have the same valence Contradiction bivalent valent 40

There must exist two processors with different valences bivalent 41

There must exist two processors with different valences bivalent 41

Case 1: suppose that they access different shared variables bivalent Re Re ad dx

Case 1: suppose that they access different shared variables bivalent Re Re ad dx a x y y 42

two possible executions bivalent Re Re ad dx a Read y different valence impossible

two possible executions bivalent Re Re ad dx a Read y different valence impossible since y Read x 43

same result holds for any kind of operation (Read or Write) that the processors

same result holds for any kind of operation (Read or Write) that the processors apply to x and y 44

Case 2: suppose that they access the same shared variable subcase: read/read bivalent Re

Case 2: suppose that they access the same shared variable subcase: read/read bivalent Re Re ad dx a x x 45

two possible executions bivalent Re Re ad dx a Read x different valence impossible

two possible executions bivalent Re Re ad dx a Read x different valence impossible since x Read x 46

subcase: read/write bivalent Re W ri x d a te x 47

subcase: read/write bivalent Re W ri x d a te x 47

two possible executions bivalent Re W ri dx a te x Write x different

two possible executions bivalent Re W ri dx a te x Write x different valence impossible since Read x 48

subcase: write/write bivalent x e it r W W ri te x Write x

subcase: write/write bivalent x e it r W W ri te x Write x different valence impossible since Write x 49

In all cases we obtained contradiction Therefore, there exists a processor which is not

In all cases we obtained contradiction Therefore, there exists a processor which is not critical univalent bivalent (not critical) End of Lemma Proof univalent 50

Therefore, we can construct an execution bivalent Initial configuration bivalent Never ends Consensus can

Therefore, we can construct an execution bivalent Initial configuration bivalent Never ends Consensus can never be reached End of Theorem Proof 51