简体   繁体   English

顺序一致但不可线性化的执行

[英]Sequentially consistent but not linearizable execution

I'm trying to understand the difference between linearizability and sequential consistency. 我试图理解线性化和顺序一致性之间的区别。 More specifically, I would like to have an example of an execution which is sequentially consistent but not linearizable. 更具体地说,我想有一个顺序一致但不可线性化的执行示例。 My professor gave me the following example of such execution: 我的教授给了我以下这样执行的例子:

Alice and bob write checks to each other.
Alice’s Statement:
-10  Check Alice -> Bob
0  Check Bob -> Alice

Bob’s Statement
-10  Check Bob -> Alice
0  Check Alice -> Bob

Both overdraft.
It is sequential: each client sees a consistent order
It is not linearizable: no globally linear story 

But I didn't get it. 但我没有得到它。 Line 线

n Check A -> B

is supposed to be interpreted as "A writes a check to B and its account after the operation is n". 应该被解释为“A在操作为n后将检查写入B及其帐户”。 I don't understand why the operation shouldn't be linearisable: both Alice and Bob end up with 0 in the end which is a consistent value, so maybe I didn't get the definition of 'linearisability' properly. 我不明白为什么操作不应该是可线性的:Alice和Bob最终都是0,这是一个一致的值,所以也许我没有正确地得到'linearisability'的定义。

First off, what your professor gave you is not the history/execution explicitly, but the projection of the history on both of its threads. 首先,你的教授给你的不是历史/执行,而是历史在两个线程上的投射。

A history H is linearizable if by leaving away pending invocations and/or adding responses to pending invocations (that you didn't leave away) you can get a history that is equivalent to a sequential history S that doesn't contradict any precedences implied by H. 如果通过遗漏待处理的调用和/或添加对未决调用的响应(您没有离开),历史H是可线性化的,您可以获得一个等同于顺序历史S的历史记录,该历史记录不会与任何优先级相矛盾。 H。

In other words, the reason your example is not linearizable is because the operations (financial transactions) can't be assigned a single point in time. 换句话说,您的示例不可线性化的原因是因为无法在单个时间点分配操作(财务事务)。 First money is deducted, and then later added, and this behaviour is observed by the threads/individual bank statements. 扣除第一笔钱,然后再添加,并且线程/个别银行对账单会观察到此行为。

If the bank statements were 如果银行对账单是

Alice’s Statement:
-10  Check Alice -> Bob
0  Check Bob -> Alice

Bob’s Statement
10  Check Alice -> Bob
0  Check Bob -> Alice

then we would have a history S as follows: 然后我们将有一个历史S如下:

Alice: Send Bob 10
Alice: Send completed
Bob:   Send Alice 10
Bob:   Send completed

But in your example the history could be 但在你的例子中,历史可能是

Alice: Send Bob 10 (i.e. money is gone)
Bob:   Send Alice 10 (i.e. money is gone)
Bob:   Send completed (i.e. money arrived)
Alice: Send completed (i.e. money arrived)

(or any combination of lines 1/2 switched and 3/4 switched) and you can't reorder that sequentially (ie pairs of started/completed together) without changing the account balance observed by each thread in between. (或1/2线切换和3/4切换的任意组合)并且您不能按顺序重新排序(即一起开始/完成的对)而不改变其间每个线程观察到的账户余额。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM