1

I don't understand these. Let's say I have a value 10 at memory address x.

If we have

thread1:
Read(x)
x+=5
Write(x)

and then:

thread2:
Read(x)
x+=2
Write(x)

I don't get what is valid sequential or strict consistency.

Like, here, is this a valid strictly consistent operations result?

T1: R(x), found 10                W(x), x is now 15
T2                 R(x),found 10                     W(x), x is now 12

That seems so useless. x has the wrong value... it wasn't additive. That said, the accesses executed by each processor were kept in-order and the same order was seen by everyone. Those are the criterion for strict consistency, right? It doesn't matter that the result got crushed.

And for a sequential consistency... I don't get the distinction between it and strict.

4

1 回答 1

1

部分解决您的问题:

顺序一致性,只要求内存位置按照它们发出的顺序查看操作。从主线程(时钟)的角度来看,发出这些操作的方式可能并不理想。

但是,它们仍然是顺序一致的。我自己的解释是,在发布后对内存位置的操作进行重新排序,将违反一致性要求。就好像,在发行时已经获得了一张全局票,并且执行引擎尊重票的排序。

如果我们可以称之为“问题”,那就是指令问题本身——因为 T1 和 T2 可以自由地以任何顺序发出它们。如果应用程序对这种一致性水平感到满意,它应该愉快地使用它。

一个假设的情况:让我们希望某个内存位置由多个线程更新,并且所有线程完成后的读取器必须读取最后写入的值 - 您只需要最后一个按发出顺序获胜。当然,这是一种狭隘的情况,但在某些情况下是一种理想的情况。

于 2014-12-04T23:23:17.523 回答