master-degree-notes/Concurrent Systems/notes/10 - Consensus Implementation.md

42 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Which objects allow for a wait free implementation of (binary) consensus? The answer depends on the number of participants
The **consensus number** of an object of type T is the greatest number n such that it is possible to wait free implement a consensus object in a system of n processes by only using objects of type T and atomic R/W registers.
For all T, CN(T) > 0; if there is no sup, we let CN(T) := +∞
**Thm:** let CN(T1) < CN(T2), then there exists no wait free implementation of T2 that only uses objects of type T1 and atomic R/W registers, for all n s.t. CN(T1) < n <= CN(T2).
*Proof:*
- Fix such an n; by contr., there exists a wait free implementation of objects of type T2 in a system of n processes that only uses objects of type T1 and atomic RW reg.s.
- Since n CN(T2), by def. of CN, there exists a wait free implementation of consensus in a system of n processes that only uses objects of type T2 and atomic RW reg.s.
- Hence, there exists a wait free implementation of consensus in a system of n processes that only uses objects of type T1 and atomic RW reg.s.
- contradiction with CN(T1) < n
### Schedules and Configurations
**Schedule:** sequence of operation invocations issued by processes.
**Configuration:** the global state of a system at a given execution time (values of the shared memory + local state of every process).
Given a configuration C and a schedule S, we denote with S(C) the configuration obtained starting from C and applying S.
Let's consider binary consensus implemented by an algorithm A by using base objects and atomic R/W registers; let us call $S_A$ a schedule induced by A.
A configuration C obtained during the execution of all A is called:
- **v-valent** if $S_A(C)$ decides v, for every $S_A$
- **monovalent**, if there exists $v \in \{0,1\}$ s.t. C is v-valent
- **bivalent**, otherwise.
### Fundamental theorem
If A wait-free implements binary consensus for n processes, then there exists a bivalent initial configuration.
*Proof:*
![[Pasted image 20250401083747.png]]
### CN(Atomic R/W registers) = 1
**Thm:** There exists no wait-free implementation of binary consensus for 2 processes that uses atomic R/W registers.
*Proof:*
Assume by contradiction A wait-free, with processes p and q.
By the previous result, it has an initial bivalent configuration C
- let S be a sequence of operations s.t. C = S(C) is maximally bivalent (i.e., p(S(C)) is 0-valent and q(S(C)) is 1-valent, or viceversa)