• Aucun résultat trouvé

Introduction to

N/A
N/A
Protected

Academic year: 2022

Partager "Introduction to"

Copied!
8
0
0

Texte intégral

(1)

Introduction to

Distributed Algorithms and Systems

Achour Most´efaoui

Irisa/Ifsic, Universit´e de Rennes achour@irisa.fr

http://www.irisa.fr/asap/

Master 2 Recherche en Informatique - Octobre 2010 1

Plan

• Basic problems and computing model

• Synchronization: specification and solution design

• Qualities of a distributed algorithm

• A first example: implementing a FIFO channel

• Mutual Exclusion: the come-back

Master 2 Recherche en Informatique - Octobre 2010 2

Context (1)

What is a distributed architecture?

• A set of processors

• A communication medium (bus, network, shared mem- ory, etc.)

Context (2)

What is a distributed system?

• A set of processes

• A set of communication services

Above a distributed architecture.

(2)

Context (3) What is a distributed computation?

• Parallel computation:

⋆ Several processors

⋆ One (or more) process(es) per processor

• Communication

⋆ By shared memory, or

⋆ By exchanging messages

Over a distributed system.

Master 2 Recherche en Informatique - Octobre 2010 5

Context (4)

Modeling of a distributed computation

• Lattice of global states

• Execution traces (interleavings)

Master 2 Recherche en Informatique - Octobre 2010 6

Synchronization Control of the activity of processes.

This means to forbid some interleavings from happening according to the specification of the problem to solve.

There exist several basic synchronization problems.

A non trivial task if the system is asynchronous

• Safety

• Liveness

Asynchronous Distributed System Model (1)

Advantages

• Better fault-tolerance (decentralization of decisions)

• Better efficiency

⋆ Distribution of the load (parallelism)

⋆ Relative Autonomyof the processes (asynchronism)

⇒ loosely coupled: less risk of mutual blocking

(3)

Asynchronous Distributed System Model (2)

Drawbacks

• Process control is harder due to:

⋆ Asynchronism: Impossibility to instantaneously eval- uate predicates on several processes

⋆ Failures: Hardness to maintain the consistency of a computation

⋆ The conjunction of the two: How to distinguish a slow process from a failed process?

Master 2 Recherche en Informatique - Octobre 2010 9

Synchronization Problems

Rules and mechanisms to ensure a correct evolution of the processes

• Competition problems:

Each process a priori ”ignores” the existence of the other processes (they are useless for him)

• Cooperation problems:

Each process needs to cooperate with others to do its part of the job

Master 2 Recherche en Informatique - Octobre 2010 10

Synchronization Problems

Paradigms

• Competition

⋆ Mutual Exclusion

⋆ Resource Allocation

• Cooperation

⋆ Generalized Rendezvous

⋆ Maintain a global invariant

⋆ Build a global virtual time

A Simple Synchronization Problem: FIFO Channel

Messages sent on a given channel are delivered to the des- tination process in the sending order

• Specification: send(m1)→send(m2)⇒rec(m1)→rec(m2)

• Which mechanism to use to implement the needed syn- chronization?

(4)

Qualities of a Distributed Algorithm

• Number of exchanged messages

• Size of needed memory

• Correctness

• Complexity of the design

• . . .

Master 2 Recherche en Informatique - Octobre 2010 13

Importance of the Context

The context where the algorithm will be used deeply im- pacts the choice of the solution to a problem.

Example

Master 2 Recherche en Informatique - Octobre 2010 14

Mutual Exclusion: Reminder (1)

Access to a shared resource by at most one process at once

• Obtain a write lock on a shared file

• Consistent update of copies of a replicated data

Methodological importance

Mutual Exclusion: the Problem (2)

Algorithmic formulation:

• Each process Pi has a variable statei∈ {out, asking, in}

• Each Pi can invoke enter cs, exit cs

(5)

Mutual Exclusion: Structure of a Protocol (3)

Structure of a mutual exclusion protocol

For each process Pi

Preamble {statei =out} enter cs; {statei =asking}

wait-privilege ; {statei =in}

<Critical Section>

Postlude exit cs; {statei =out}

Master 2 Recherche en Informatique - Octobre 2010 17

Mutual Exclusion: Modeling

enter_cs

out asking

in

exit_cs ?

Problem: Transition from the state asking to the state in.

The to transitions enter cs and exit cs are entailed by the process itself.

The transition asking −→ in is triggered by the mutual exclusion protocol.

Master 2 Recherche en Informatique - Octobre 2010 18

Mutual Exclusion: Specification

Specification of the solution

• Safety: at most one process in the state in

• Liveness: any process in the state asking becomes in after a finite time (no deadlock, no starvation)

Mutual Exclusion: Classes of Solutions

Two main classes :

• Protocols based on Permissions

Obtain the priviledge ≡ obtain enough permissions Safety: exclusive permissions

• Protocols based on the use of a token Obtain the privilege ≡ have the token Safety: uniqueness of the token

(6)

Token Protocols (1)

• Safety:

Having a unique token ensures to its owner the right to enter the critical section

• Advantage: no need of timestamping

• Problems:

⋆ Ensure liveness

⋆ Loss of the token

Master 2 Recherche en Informatique - Octobre 2010 21

Token Protocols (2)

Two strategies

1. Passive: wait for the token (no explicit request). The liveness is ensured if the token reaches all parts of the network (e.g. ring)

2. Active: explicit request sent to the potential owner of the token. The liveness is ensured if any request even- tually reaches the token, and if fairness is guaranteed.

Master 2 Recherche en Informatique - Octobre 2010 22

Active Strategy: K. Raymond

The network is logically structured as a tree (static) A dynamic structure is mapped onto the tree structure orientation of the edges

Invariant:

• Each node has a unique father: orientation towards THE sub-tree that contains the token

• The owner of the token is the Root

Protocol of K. Raymond: Example (1)

1

6

2

3

5

4

7

8

9

(7)

Protocol of K. Raymond: Example (2)

1

6

2

3

5

7

8

9

000000 000000 000 111111 111111 111

4

P4 is the owner of the token

P1 requests the token from its father P2, which requests it from its own father P4

Master 2 Recherche en Informatique - Octobre 2010 25

Protocol of K. Raymond: Example (3)

6

2

3

5

7

8

9

Transfert of the token from P4 to P1 via P2

000000 000000 000 111111 111111 111

4 1

INVERSION OF THE EDGES

:

Master 2 Recherche en Informatique - Octobre 2010 26

Protocol of K. Raymond: Concurrent Requests

Each process plays the role of a proxy node for the account of one of its sons from which it received a Request.

Request from the sons are stored in FIFO order in awaiting queue local to each process.

Empty queue: the process is not asking

Non-empty queue: the process is asking for a request that is stored in its queue.

Reception of the token: the process satisfies the request at the head of the queue.

Protocol of K. Raymond (1)

varstatei: (out, asking, in) f atheri: process id;

qi: queue of process id;

proc enter cs begin

statei = asking;

if f atheri=null

then /* pi has the token */ statei = in else store i in qi

if |qi|= 1 then send request(i) to f atheri endif endif

end

(8)

Protocol of K. Raymond (2)

proc exit cs begin

statei=out;

if qi non empty

then let j be the head of qi; remove j from qi; send token to pj;

f atheri=j;

if |qi| 6= 0 then send request(i) to f atheri; endif endif

end

Master 2 Recherche en Informatique - Octobre 2010 29

Protocol of K. Raymond (3)

Upon the reception of request(j) begin

if f atheri=null

then /* pi has the token */

if statei=in

then store j in qi

else send token to pj; f atheri =j endif

else /* pi does not have the token */

store i in qi ;

if |qi|= 1 then send request(i) to f atheri endif endif

end

Master 2 Recherche en Informatique - Octobre 2010 30

Protocol of K. Raymond (4)

Upon the reception of token begin

f atheri=null;

Let j be the head of qi; remove j from qi; if j =i

then statei =in /* enter the SC */

else send token to pj f atheri=j;

if |qi| 6= 0 then send request(i) to f atheri; endif endif

end

Références

Documents relatifs

Si tous les animaux produisent des crottes, elles sont très différentes d’une espèce à l’autre!. Il en existe de toutes les formes, de toutes les consistances et de beaucoup de

Die Resultate der Studie zeigen, dass trotz einem erhöhten Risiko zu psychischen Folgen eines Einsatzes Rettungshelfer Zufriedenheit und Sinn in ihrer Arbeit finden können und

Nous souscrivons donc aux recommandations européennes les plus récentes concernant le traitement anticoagulant et antiagrégant des patients atteints de fibrillation auriculaire (et

Nous invitons toutes les personnes qui ont une passion quelle qu’elle soit et qui souhaiteraient la partager avec les enfants de nos villages, à nous contacter pour ajouter

Ein verwandt- schaftliches Empfinden ergab sich vor allem aus dem gemeinsamen Status einer Republik, aber auch aufgrund der ähnliehen politischen Institutionen und

[r]

C’était le moment choisi par l’aïeul, […] pour réaliser le vœu si longtemps caressé d’ accroître son troupeau que les sècheresses, les épizoodies et la rouerie de

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des