Concurrency - Universality of Consensus
CommentUniversality of Consensus
How to prove statements of the form “there is no wait-free implementation of $X$ by $Y$”?
6.2 Universality
A class $C$ is universal if one can construct a wait-free implementation of any object from some number of objects of $C$ and some number of read-write registers.
6.3 A Lock-Free Universal Construction
1 | public interface SeqObject { |
(the apply()
method applies the invocation and returns a response).
1 | public class Node { |
This shows a universal construction that transforms any sequential object into a lock-free linearizable concurrent object. This construction assumes that sequential objects are deterministic: if we apply a method to an object in a particular state, then there is only one possible response, and one possible new object state. We can represent any object as a combination of a sequential object in its initial state and a log: a linked list of nodes representing the sequence of method calls applied to the object (and hence the object’s sequence of state transitions).
我们只要存下调用序列就可以知道状态了。
那么怎么让它并发呢?也就是 apply()
能够并发地被调用。
只要在调用 apply()
的时候,都创建一个 node
,通过一个 $n$-线程的共识协议来竞争哪一个节点被添加到调用序列当中。
赢者得到执行(什么达尔文),它把对象复制到本地,然后顺序执行(真的不计内存消耗了?)最后返回自己的结果。
败者就必须继续竞争(所以不是 wait-free)
详细的暂时不看了。
6.4 A Wait-Free Universal Construction
Core: help less fortunate threads to complete their calls. helping
1 | public class Universal { |
我的智商不够看懂这个(懒)
7 就是 spinlock 了,终于有锁了,流下了激动的眼泪。