Parallel and Distributed Algorithm-2

Preliminary & Basic algorithm

1.The state of a process = its own state (the values of its variables) + the content of its input channels + the content of its output channels

2.Message-passing: = send/broadcast + receive

3.The state of a system (configuration) = an ordered list of all local states (one per process) at a certain moment of time

4.Causal Order and Logical Clocks

5.

6.Models of Communication:FIFO, non-FIFO, Causal

7.Snapshots:A snapshot of an execution of a distributed algorithm A is a configuration of this execution, consisting of local states of the processes and the messages on the channels .

Snapshots are used on:

• Deadlock

• Termination

• Garbage

8.There will be two types of messages in the channels:

– Messages of the snapshot algorithm, called control messages

– Messages of the basic algorithm A, called basic messages

9.

10. Chandy-Lamport Algorithm:

unidirectional, FIFO, decentralized

A <marker> msg. separates the messages in the channel into those to be included in the snapshot from those not to be recorded in the snapshot.

The Chandy-Lamport algorithm works like this:

  1. The observer process (the process taking a snapshot):
    1. Saves its own local state
    2. Sends a snapshot request message bearing a snapshot token( <marker> ) to all other processes
  2. A process receiving the snapshot token for the first time on anymessage:
    1. Sends the observer process its own saved state
    2. Attaches the snapshot token to all subsequent messages (to help propagate the snapshot token)
  3. When a process that has already received the snapshot token receives a message that does not bear the snapshot token, this process will forward that message to the observer process. This message was obviously sent before the snapshot “cut off” (as it does not bear a snapshot token and thus must have come from before the snapshot token was sent out) and needs to be included in the snapshot.

From this, the observer builds up a complete snapshot: a saved state for each process and all messages “in the ether” are saved.

Time complexity: O(D) time units to complete, where D is the diameter of the network

11. Lai-Yang Algorithm:

non-FIFO,

As long as a process has not taken a local snapshot, it appends false to each outgoing basic message, after it takes the local snapshot, it appends true to these messages.

When a process that has not yet taken a local snapshot receives a message with the tagtrue, it takes a local snapshot of its state before the receiving of this message

A process q computes as channel state of an incoming channel pq the basic messages with the tag false that it receives through this channel after having its local snapshot.

– Every process is initially white and turns red while taking a snapshot.

– Every message sent by a white process is colored white.

– Every message sent by a red process is colored red.

– Thus, a white message is a message that was sent before the sender of that message recorded its local snapshot.

– Thus, a red message is a message that was sent after the sender of that message recorded its local snapshot.

– Every white process takes its snapshot at its convenience, but no later than the instant it receives a red message.

– Every white process records a history of all white messages sent or received by it along each channel.

– When a process turns red, it sends these histories along with its snapshot to the initiator process that collects the global snapshot.

– The initiator process computes the state of a channel CSij:

CSij = white messages sent by Pi on channel Cij minus the white messages received by pj on Cij

CSij = {send(mij)|send(mij) ∈ LSi } — {rec(mij)|rec(mij) ∈ LSj }.

Complication 1: If after its local snapshot, an initiator will not send any basic messages, then “true” or “false” will not be appended to any of its outgoing messages, so other processes that can be reached only from that process will not get a chance to take ever a local snapshot.

Complication 2: How does a process know to stop waiting for messages with “false” tag attached to it and make the decision of taking a local snapshot, then compute the channel state of an incoming channel?

These issues can be addressed by adding a special control message <special, no> sent by a process p into all its outgoing channels :

• The msg sent by p into the channel pq indicates how many (<no>) basic messages with the tag false were sent by p into the channel pq

• On receiving a <special> msg, process q takes a local snapshot if it has not done yet so

12.Waves:A process broadcasts a request and the other processes reply with the required information.

Examples:detecting termination, routing, election of a leader in the network

13.Traversal Algorithms:

centralized wave algorithm,

Traversal algorithms build a spanning tree:

– the initiator is the root

– each non-initiator has as parent the neighbor from which it has received the token first.

Example: the ring algorithm, Tarry’s algorithm, depth-first search algorithm

14. Ring Algorithm:

– an initiator send a token to one of the two neighboring processes

– On receiving a token, a process sends it to the other neighboring process (from which it has not received the token)

– The initiator decides after the token has returned.

– The initiator will receive the token after the token makes one trip around the ring.

15.Tarry’s Algorithm:

R1: A process never forwards the token through the same channel twice.

R2: A process only forwards the token to its parent when there is no other option.

• The token travels through each channel both ways, and finally ends up at the initiator.

• Requires 2E messages and it takes at most 2E time units to terminate.

16.Depth First Search:

The process from which a token is received the first time is called the parent.

Starting with the initiator, whenever possible, forward the token to a process that did not hold the token yet.

If a process holding the token has no unvisited neighbor, send the token back to the parent.

17.Tree Algorithm:

de-centralized, undirected, acyclic( If the network contains cycles, the algorithm does not terminate )

– A process p waits until it has received messages from all its neighbors except one; then p makes that node as its parent and sends a message to it.

– When p receives a message from its parent, it decides. Always exactly two processes in the network decide, and these two consider each other their parent.

18.Echo Algorithm:

centralized, undirected

• The initiator broadcasts a message to all its neighbors

• When a non-initiator receives a message for the first time, it makes the sender to be its parent, and broadcasts the message to all its neighbors except the parent

• When a non-initiator has received messages from all its neighbors, it sends the message to its parent

• When the initiator has received messages from all its neighbors, it decides

• The echo algorithm takes 2E messages to 2N-2 time units to terminate


猜你喜欢

转载自blog.csdn.net/francislucien2017/article/details/78433943