I understand that in sequential consistency all processes have to be processed sequentially. For example:
我理解,在顺序一致性中,所有进程都必须按顺序处理。例如:
Process 1 Process 2
x = 1 z = 5
y = 2 p = 3
So, we can get x=1, z=5, y=2, p=3 or z=5, p=3, x=1, y=2. But what matters is that p can only be executed once z is executed etc, correct?
我们可以得到x=1 z=5 y=2 p=3或z=5 p=3 x=1 y=2。但重要的是p只能在z执行之后才能执行,对吧?
What about causal consistency? I don't see any difference there. Any sketches, or code in JAVA or C would be great. Thank you.
因果一致性呢?我看不出有什么不同。任何草图或JAVA或C语言的代码都很好。谢谢你!
1 个解决方案
#1
3
In sequential consistency all of the memory operations appear to all nodes to have appeared in some order.
在序列一致性中,所有内存操作在所有节点上都以某种顺序出现。
So in your example processes 1, 2, and 3 would all see the memory operations in the same order. (There are 6 possible orders for the 4 operations, but all the processes would agree on what that order is.)
在你的例子中,进程1 2和3会以相同的顺序显示内存操作。(这4个操作有6个可能的订单,但所有流程都同意这个订单是什么。)
In causal consistency processes 1, 2 and 3 could all observe those writes to occur in different orders. There are two rules:
在因果一致性过程中,1、2和3都可以观察到这些写操作以不同的顺序出现。有两个规则:
- Everyone agrees that process i's writes happened in the same order that process i did them.
- 每个人都同意我写的过程和我写的过程是一样的。
- If any process, i, does a read of a location
x
and gets a value that was written by a different process, j, then all the threads agree that process j's write to location x preceded process i's read of location x. - 如果任何进程,i,读取位置x并获取由另一个进程j写入的值,那么所有线程都同意进程j对位置x的写入先于进程i对位置x的读取。
Since, in your original example there are no read operations then it is possible, for example, for process 1 to believe that the writes happened in the order x=1, y=2, z=5, p=3
while process 2 believes that the writes happened in the order z=5, p=3, x=1, y=2
and process 3 believes that they happened in order z=5, x=1, p=3, y=2
.
以后,在你原来的例子没有读操作是可能的,例如,进程1相信写发生在订单x = 1,y = 2,z = 5,p = 3,过程2认为写的顺序发生了z = 5,p = 3,x = 1,y = 2和过程3认为他们发生z = 5,x = 1,p = 3,y = 2。
The paper that the Wikipedia page points to gives some examples that are more interesting (involve reads).
*页面指向的那篇论文给出了一些更有趣的例子(包括阅读)。
Causal memory by itself seems not very useful. Later in the paper they show how to implement something kind of like a barrier with a causal memory (and a helper process), but mention that there doesn't seem to be any convenient way to implement a critical section.
因果记忆本身似乎不是很有用。在论文的后面,他们展示了如何实现某种类似于一个具有因果性记忆的障碍(以及一个辅助过程),但是提到了实现一个关键部分似乎没有任何方便的方法。
So they end up doing what weakly consistent or release consistent memories do, and adding a synchronization primitive, which needs to be sequentially consistent.
所以他们最终做了弱一致性或释放一致性记忆的事情,并添加了一个同步原语,它需要顺序一致。
#1
3
In sequential consistency all of the memory operations appear to all nodes to have appeared in some order.
在序列一致性中,所有内存操作在所有节点上都以某种顺序出现。
So in your example processes 1, 2, and 3 would all see the memory operations in the same order. (There are 6 possible orders for the 4 operations, but all the processes would agree on what that order is.)
在你的例子中,进程1 2和3会以相同的顺序显示内存操作。(这4个操作有6个可能的订单,但所有流程都同意这个订单是什么。)
In causal consistency processes 1, 2 and 3 could all observe those writes to occur in different orders. There are two rules:
在因果一致性过程中,1、2和3都可以观察到这些写操作以不同的顺序出现。有两个规则:
- Everyone agrees that process i's writes happened in the same order that process i did them.
- 每个人都同意我写的过程和我写的过程是一样的。
- If any process, i, does a read of a location
x
and gets a value that was written by a different process, j, then all the threads agree that process j's write to location x preceded process i's read of location x. - 如果任何进程,i,读取位置x并获取由另一个进程j写入的值,那么所有线程都同意进程j对位置x的写入先于进程i对位置x的读取。
Since, in your original example there are no read operations then it is possible, for example, for process 1 to believe that the writes happened in the order x=1, y=2, z=5, p=3
while process 2 believes that the writes happened in the order z=5, p=3, x=1, y=2
and process 3 believes that they happened in order z=5, x=1, p=3, y=2
.
以后,在你原来的例子没有读操作是可能的,例如,进程1相信写发生在订单x = 1,y = 2,z = 5,p = 3,过程2认为写的顺序发生了z = 5,p = 3,x = 1,y = 2和过程3认为他们发生z = 5,x = 1,p = 3,y = 2。
The paper that the Wikipedia page points to gives some examples that are more interesting (involve reads).
*页面指向的那篇论文给出了一些更有趣的例子(包括阅读)。
Causal memory by itself seems not very useful. Later in the paper they show how to implement something kind of like a barrier with a causal memory (and a helper process), but mention that there doesn't seem to be any convenient way to implement a critical section.
因果记忆本身似乎不是很有用。在论文的后面,他们展示了如何实现某种类似于一个具有因果性记忆的障碍(以及一个辅助过程),但是提到了实现一个关键部分似乎没有任何方便的方法。
So they end up doing what weakly consistent or release consistent memories do, and adding a synchronization primitive, which needs to be sequentially consistent.
所以他们最终做了弱一致性或释放一致性记忆的事情,并添加了一个同步原语,它需要顺序一致。