Motivation

For sequential we can use Hoare-Logic to argue about correctness. For concurrent programs this is not possible, as we can not look at methods in isolation.

We need a formal notation to talk about concurrent code

Definition

Definition

History sequence of invocations and responses

Projections

Thread

Definition

= subhistory of , with only the calls in thread

Object

Definition

= subhistory of H, with only the calls on obj (e.g. a datastructure)

  • all object projections are legal sequential programs (i.e. possible, fulfil pre- & postconds)

Example of projections

Characterisations

complete

Definition

A history is complete, when it has no pending invocations

  • i.e. to each invocation, there was a response

sequential

Definition

every method call finishes (response) before next starts (invocation)

  • but it’s okay if last invocation is still pending

well-formed

Definition

A history  is well-formed if each thread’s subhistory  is sequential.

equivalent

Definition

Two histories  and  are equivalent if for every thread , the subhistory , i.e.

  • Individual threads execute the same commands in the same intra-thread order
  • The histories are two different interleavings of the same program

Defintiion

A sequential history is legal if for every object adheres to the sequential specification of (i.e. Pre- & Postconditions)

Precedence

Defintiion

Given: history and method executions and on

is a Relation and implies partial order on

**The order is total when is sequential!

Examples

Example

Sequential Consistency

  • We want guarantees from our soft- and hardware which interleavings they allow and which not.

Definition

History H is sequentially consistent if it can be extended to a history G…

  • appending 0 responses to pending invocations that took effect.
  • discarding 0 pending invocations that did not take effect. …So that G is equivalent to a legal sequential history S.

Task strategy - how to figure out if a history is seq. cons.?

  1. Find all pending invocations. Whose effects are already visible in the effects of other calls? add responses Effects are invisible? remove the invocation
  2. Move methods around to form a logical sequential history. Cannot move them between threads Must not skip other methods within the same thread (preserve intra-thread orders)

If not possible, then not sequentially consistent.

Taking Effect

…Linearizability is stronger: H is linearizable iff H is sequentially consistent and…