I read this answer below and got into another question.
I also read that read/write registers have consensus number 1.
But I see that in test&set (also in compare&swap) by using read write registers alone, we still arrive at consensus.
I think I am missing something very fundamental here. Need help.
The protocol in the accepted answer of the link is as mentioned below
Suppose that we have two threads 0 and 1 that need to reach consensus. We could do this by letting each thread follow the consensus protocol below:
- Write your proposed value to A[t], where t is the thread id and A is an array of size 2
- Perform the test-and-set instruction on some register R, with R initialised to 0.
- If the return value is 0, you were first: return A[t]. Otherwise, you were second: return A[|t−1|].