Consistency

Consistency: Specifies what behaviour is allowed when a shared object is accessed by multiple procs.

Shared object: Abstract Data Type that supports access from multiple processes.

Mutual exclusion is actually a way to ensure consistency by preventing unwanted behaviour

Sequential consistency

Lamport’s informal definition: The results are the same as if all operations by multiple processors were executed in some sequential order specified by the program (i.e. executed by a single processor with no interleaving operations.)

Formalism

Operation: An invocation/response pair of a single shared object by a process

History $H$: sequence of inv/res totally ordered by wall clock time

Sequential history:

How to tell if a history is sequential:

Legal sequential history:

Subhistory: The subsequence of all events of either process $p$ or object $o$.

Equivalency: Two histories equivalent if they have the same set of events, implying all responses’ values are the same (though event ordering may be different).

Sequentially consistent history $H$ formal definition

History $H$ is sequentially consistent if

  1. it is equivalent to some legal sequential history $S$
    1. Legal means the response must be valid semantically
    2. Sequential means the response must immediately follow invocation in each process
  2. and $S$ preserves the program order in $H$.
    1. You are free to reorder the interleaving of operations across processes.

Linearizability

Linearizability: Induces $<_H$ partial order. $o_1 <_H o_2$ if $resp(o_1) < resp(o_2)$ in $H$ (occured-before order).

This order is known as external order.

Linearizable history $H$:

Local property

Linearizability is a local property.

$H$ is linearizable if and only if $H \mid x$ is linearizable (for any object $x$).

Sequential consistency is not a local property. See slides for example.

Proof of linearizability being a local property

$H$ is linearizable if and only if $H \mid x$ is linearizable (for any object $x$).

Only if (trivial): if $H$ is linearizable, then it is equivalent to some legal sequential history $S$ that adheres to external order from $H$. The subhistory $S \mid x$ must also still be a legal sequential history that adheres to external order from $H$ which includes $H \mid x$. This shows that $H \mid x$ is linearizable

If (nontrivial): Suppose $H \mid x$ is linearizable for any object $x$.

We define a digraph $G$ such that each op is a node in $G$, and each pair of nodes $a,b$ has an edge $a \rightarrow b$

DAG

Lemma: The digraph $G$ will always be a DAG.

Proof: Suppose for contradiction that a cycle may exist. Such a cycle must be of the form $A \rightarrow B \rightarrow C \rightarrow D \rightarrow A$

  1. $A \rightarrow B$ due to obj x
  2. $B \rightarrow C$ due to H
    1. We can’t not have this as $B$ cannot be in both $H \mid x$ and $H \mid y$ by definition (operations are always on a single shared object).
  3. $C \rightarrow D$ due to obj y
  4. $D \rightarrow A$ due to H
    1. see $B \rightarrow C$

Since $H$ has an external order imposed by wall clock time and $H \mid y$ also preserves external order, then $B < C < D < A$. However since $H \mid x$ also preserves external order we need $A < B$ to hold as well. Hence we have a contradiction.

Proof of local property: By lemma, we know that we can always achieve a topological ordering of the operations in the history $H$ across all the objs. Hence this ordering $S$ is a sequential history that adheres to the external order.

But is $S$ legal?

Proof of the equivalence of the two definitions

Def 1 $\Rightarrow$ Def 2.

Def 2 $\Rightarrow$ Def 1.

Let the legal sequential history $S$ be $a, b, c \dots$.

Def2 => Def1

Def2 => Def1 prove buffer part