45
Asynchronous Model Etienne Renault 18 d´ ecembre 2017 https://www.lrde.epita.fr/ ~ renault/teaching/algorep/ Etienne Renault algorep 18 d´ ecembre 2017 1 / 18

Etienne Renault - lrde.epita.frrenault/teaching/algorep/6-async-model.pdf · Etienne Renault algorep 18 d ecembre 2017 6 / 18. Formally : Actions Let us consider S the set of actions

  • Upload
    others

  • View
    20

  • Download
    0

Embed Size (px)

Citation preview

Asynchronous Model

Etienne Renault

18 decembre 2017

https://www.lrde.epita.fr/~renault/teaching/algorep/

Etienne Renault algorep 18 decembre 2017 1 / 18

Observations

Synchronous NetworksBasic, easy to program

Impossibility for synchronous network carry over worse networks

. . . but they are not realistic

We need another model to simulate real-world behavior !

Etienne Renault algorep 18 decembre 2017 2 / 18

Observations

Synchronous NetworksBasic, easy to program

Impossibility for synchronous network carry over worse networks

. . . but they are not realistic

We need another model to simulate real-world behavior !

Etienne Renault algorep 18 decembre 2017 2 / 18

1 Asynchronous Shared Memory

2 Asynchronous Network

3 Fairness

4 From Shared Memory to Network

Etienne Renault algorep 18 decembre 2017 3 / 18

Asynchronous Shared Memory Model

What it is ?A collection of communicating processes

Information is exchanged via shared memory rather than viamessage passing

Why to use it ?Between Synchronous model and Asynchronous Network model

Some algorithms are easily adaptable from shared memory toasynchronous model

Etienne Renault algorep 18 decembre 2017 4 / 18

Is it realistic ?

Symmetric Multiprocessing (SM)

Non uniform memory access (NUMA)

Shared Memory can be simulated using only message passing

Etienne Renault algorep 18 decembre 2017 5 / 18

Is it realistic ?

Symmetric Multiprocessing (SM)

Non uniform memory access (NUMA)

Shared Memory can be simulated using only message passing

Etienne Renault algorep 18 decembre 2017 5 / 18

Is it realistic ?

Symmetric Multiprocessing (SM)

Non uniform memory access (NUMA)

Shared Memory can be simulated using only message passing

Etienne Renault algorep 18 decembre 2017 5 / 18

Asynchronous Shared Memory model

The system holds a collection of shared (read/write) variablesI Access to shared variables are assumed to occur indivisiblyI We may assume that theses variables are atomic

Processes are assume to take step in arbitrary order rather thanin synchronised rounds

If a process has a local action enabled, then it has to performthis action

I A non-fautly process cannot just stop if it still have work to do

Complexity

Closer to what we do in the sequential world

Etienne Renault algorep 18 decembre 2017 6 / 18

Asynchronous Shared Memory model

The system holds a collection of shared (read/write) variablesI Access to shared variables are assumed to occur indivisiblyI We may assume that theses variables are atomic

Processes are assume to take step in arbitrary order rather thanin synchronised rounds

If a process has a local action enabled, then it has to performthis action

I A non-fautly process cannot just stop if it still have work to do

Complexity

Closer to what we do in the sequential world

Etienne Renault algorep 18 decembre 2017 6 / 18

Asynchronous Shared Memory model

The system holds a collection of shared (read/write) variablesI Access to shared variables are assumed to occur indivisiblyI We may assume that theses variables are atomic

Processes are assume to take step in arbitrary order rather thanin synchronised rounds

If a process has a local action enabled, then it has to performthis action

I A non-fautly process cannot just stop if it still have work to do

ComplexityCloser to what we do in the sequential world

Etienne Renault algorep 18 decembre 2017 6 / 18

Formally : Actions

Let us consider S the set of actions for a process

Transitions are associated with 3 kind of actions :I Inputs/Outputs : communication with process environment

F inputs : not under process’s controlF outputs : under process’s control

I Internals : actions visible only by the process itself

SignatureThe signature of an process is the triple composed of the inputactions (in(S)), the output (out(S)), and the internal action (int(S)).

External actions : ext(S) = in(S) ∪ out(S)

Locally controlled actions : local(S) = int(S) ∪ out(S)

Etienne Renault algorep 18 decembre 2017 7 / 18

Formally : Actions

Let us consider S the set of actions for a process

Transitions are associated with 3 kind of actions :I Inputs/Outputs : communication with process environment

F inputs : not under process’s controlF outputs : under process’s control

I Internals : actions visible only by the process itself

SignatureThe signature of an process is the triple composed of the inputactions (in(S)), the output (out(S)), and the internal action (int(S)).

External actions : ext(S) = in(S) ∪ out(S)

Locally controlled actions : local(S) = int(S) ∪ out(S)

Etienne Renault algorep 18 decembre 2017 7 / 18

Formally : Actions

Let us consider S the set of actions for a process

Transitions are associated with 3 kind of actions :I Inputs/Outputs : communication with process environment

F inputs : not under process’s controlF outputs : under process’s control

I Internals : actions visible only by the process itself

SignatureThe signature of an process is the triple composed of the inputactions (in(S)), the output (out(S)), and the internal action (int(S)).

External actions : ext(S) = in(S) ∪ out(S)

Locally controlled actions : local(S) = int(S) ∪ out(S)

Etienne Renault algorep 18 decembre 2017 7 / 18

I/O automaton

An I/0 automaton A is used to represent a process in theasynchronous shared memory model. It is a 5-uple

sig(A) : a signature

states(A) : a set of state (finite or not)

start(A) : a nonempty subset of states(A) known as the initialstates

trans(A) ⊆ trans(A)× act(sig(A)× states(A)). This must havethe property tat for every state s and every input action π thereis a transition (s, π, s ′) ∈ trans(A)

tasks(A) an equivalence relation (described later)

Etienne Renault algorep 18 decembre 2017 8 / 18

I/O automaton

An I/0 automaton A is used to represent a process in theasynchronous shared memory model. It is a 5-uple

sig(A) : a signature

states(A) : a set of state (finite or not)

start(A) : a nonempty subset of states(A) known as the initialstates

trans(A) ⊆ trans(A)× act(sig(A)× states(A)). This must havethe property tat for every state s and every input action π thereis a transition (s, π, s ′) ∈ trans(A)

tasks(A) an equivalence relation (described later)

Etienne Renault algorep 18 decembre 2017 8 / 18

I/O automaton

An I/0 automaton A is used to represent a process in theasynchronous shared memory model. It is a 5-uple

sig(A) : a signature

states(A) : a set of state (finite or not)

start(A) : a nonempty subset of states(A) known as the initialstates

trans(A) ⊆ trans(A)× act(sig(A)× states(A)). This must havethe property tat for every state s and every input action π thereis a transition (s, π, s ′) ∈ trans(A)

tasks(A) an equivalence relation (described later)

Etienne Renault algorep 18 decembre 2017 8 / 18

I/O automaton

An I/0 automaton A is used to represent a process in theasynchronous shared memory model. It is a 5-uple

sig(A) : a signature

states(A) : a set of state (finite or not)

start(A) : a nonempty subset of states(A) known as the initialstates

trans(A) ⊆ trans(A)× act(sig(A)× states(A)). This must havethe property tat for every state s and every input action π thereis a transition (s, π, s ′) ∈ trans(A)

tasks(A) an equivalence relation (described later)

Etienne Renault algorep 18 decembre 2017 8 / 18

I/O automaton

An I/0 automaton A is used to represent a process in theasynchronous shared memory model. It is a 5-uple

sig(A) : a signature

states(A) : a set of state (finite or not)

start(A) : a nonempty subset of states(A) known as the initialstates

trans(A) ⊆ trans(A)× act(sig(A)× states(A)). This must havethe property tat for every state s and every input action π thereis a transition (s, π, s ′) ∈ trans(A)

tasks(A) an equivalence relation (described later)

Etienne Renault algorep 18 decembre 2017 8 / 18

Example and Composition

s1

s2

q1

q2

P1 P2

s1,q1

s2,q1 s1,q2

s2,q2

P1||P2

Etienne Renault algorep 18 decembre 2017 9 / 18

1 Asynchronous Shared Memory

2 Asynchronous Network

3 Fairness

4 From Shared Memory to Network

Etienne Renault algorep 18 decembre 2017 10 / 18

I/O automaton with channels

This time, communication between processes do not use variables

Use a graph to represent the topology of the network

Use I/O automaton with channels

Communication is performed via send/receive messages

Etienne Renault algorep 18 decembre 2017 11 / 18

Different kind of Channels

Reliable FIFO ChannelsSending a message to pi add the message into a FIFO

When pi performs a receive it pops the first element of the FIFO.

Reliable Reordering ChannelsThe order of messages is not guaranteed.

Channels with FailuresSome message may be loss (but not duplicated)

Broadcast ChannelsSend a message to every processes including the sender

Etienne Renault algorep 18 decembre 2017 12 / 18

Different kind of Channels

Reliable FIFO ChannelsSending a message to pi add the message into a FIFO

When pi performs a receive it pops the first element of the FIFO.

Reliable Reordering ChannelsThe order of messages is not guaranteed.

Channels with FailuresSome message may be loss (but not duplicated)

Broadcast ChannelsSend a message to every processes including the sender

Etienne Renault algorep 18 decembre 2017 12 / 18

Different kind of Channels

Reliable FIFO ChannelsSending a message to pi add the message into a FIFO

When pi performs a receive it pops the first element of the FIFO.

Reliable Reordering ChannelsThe order of messages is not guaranteed.

Channels with FailuresSome message may be loss (but not duplicated)

Broadcast ChannelsSend a message to every processes including the sender

Etienne Renault algorep 18 decembre 2017 12 / 18

Different kind of Channels

Reliable FIFO ChannelsSending a message to pi add the message into a FIFO

When pi performs a receive it pops the first element of the FIFO.

Reliable Reordering ChannelsThe order of messages is not guaranteed.

Channels with FailuresSome message may be loss (but not duplicated)

Broadcast ChannelsSend a message to every processes including the sender

Etienne Renault algorep 18 decembre 2017 12 / 18

1 Asynchronous Shared Memory

2 Asynchronous Network

3 Fairness

4 From Shared Memory to Network

Etienne Renault algorep 18 decembre 2017 13 / 18

Fairness

In distributed systems we are interested only in execution in which allcomponents get fair turn to perform steps.

Let us consider the composition of 2 processes with nointeractions

Not all executions are fair

s1

s2

q1

q2

P1 P2

s1,q1

s2,q1 s1,q2

s2,q2

P1||P2

Etienne Renault algorep 18 decembre 2017 14 / 18

1 Asynchronous Shared Memory

2 Asynchronous Network

3 Fairness

4 From Shared Memory to Network

Etienne Renault algorep 18 decembre 2017 15 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :

I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable x

I Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocationI When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :

I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable x

I Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocationI When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :I simulate the behavior of process i

I manage the shared variables it owns

3 When pi wants to access shared variable x

I Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocationI When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable x

I Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocationI When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable x

I Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocationI When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable xI Sends an invocation message to process j that holds variable x

I pi suspends all its local activity, pending a response to itsinvocation

I When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable xI Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocation

I When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Strategy assuming no failures

1 Each variable is assumed to be owned by a single process

2 The job of process pi is twofold :I simulate the behavior of process iI manage the shared variables it owns

3 When pi wants to access shared variable xI Sends an invocation message to process j that holds variable xI pi suspends all its local activity, pending a response to its

invocationI When the response arrives pi restarts normally

Etienne Renault algorep 18 decembre 2017 16 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copies

I Tricky, impossible for n2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copies

I Tricky, impossible for n2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copies

I Tricky, impossible for n2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copies

I Tricky, impossible for n2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copies

I Tricky, impossible for n2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copies

I Tricky, impossible for n2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Possible Improvements

Busy waiting : Notification scheme to avoid repeatedly pollingsome variable conditions

Multi-copy scheme : Several processes maintains a copy ofvariable x (if read is lot more important than writes).

I If x is a single writer, no problem for writes, but local read mayread old values

I Otherwise, writes can be performed on different order on thevarious copies

I Majority Voting Algorithms

Fault Tolerance : Each process maintains f copiesI Tricky, impossible for n

2 failures.

Etienne Renault algorep 18 decembre 2017 17 / 18

Conclusion

Conversion from network to shared memory is also possible. . . butsomewhat uninteresting.

Two models from asynchronous systems

Based-on I/O automata

For network system, I/O automata may consider various type ofchannel

Etienne Renault algorep 18 decembre 2017 18 / 18