diff --git a/Concurrent Systems/notes/10 - Consensus Implementation.md b/Concurrent Systems/notes/10 - Consensus Implementation.md index f30b265..f5c7dce 100644 --- a/Concurrent Systems/notes/10 - Consensus Implementation.md +++ b/Concurrent Systems/notes/10 - Consensus Implementation.md @@ -63,4 +63,21 @@ p(C’) can be R1.read() or R1.write(v) and q(C’) can be R2.read() or R2.write 4. R1 = R2 and both operations are a write - *Remark:* q(p(C)) = q(C) cannot be distinguished by q since the value written by p is lost after the write of q - - Then, work like in case (3). \ No newline at end of file + - Then, work like in case (3). + +### CN(Test&set) = 2 +``` +TS a test&set object init at 0 +PROP array of proposals, init at whatever + +propose(i, v) := + PROP[i] <- v + if TS.test&set() = 0 then + return PROP[i] + else + return PROP[1-i] +``` +Wait-freedom, Validity and Integrity hold by construction. + +Agreement: the first that performs test&set receives 0 and decides his proposal; the other one receives 1 and decides the other proposal. +