Distributed Algorithms

Table of Contents

Termination detection

Termination detection in e.g. diffusing computations, workpools, deadlock detection, self stabilization.

Basic algorithm terminated if each process is passive (no sends/received), and no basic messages are in transit.

Control algorithm concerns termination detection and announcement. Termination detection shouldn’t influence basic computations.

Dijkstra-Scholten algorithm

Centralised basic algorithm, undirected network.

Tree T is maintained with initiation p₀ as root, and includes all active processes. Initially, T only has p₀.

cc(p) estimates number of children of process p in T.

Shavit-Francez algorithm

Decentralised basic algorithm, undirected network.

Forest F of disjoint trees maintained, rooted in initiators.

Initially each initiator of basic algorithm constitutes tree in F

If a wave doesn’t complete, another initiator for which tree not yet disappeared will start a wave. Last tree to disappear will start a wave that completes.

Rana’s algorithm

Decentralised algorithm, undirected network.

Each basic message is acknowledged. Lamport’s logical clock provides control events with a time stamp. Time stamp of process is highest time stamp of its control events so far (initially 0).

Let process p at time t become quiet, i.e. p is passive and all basic messages it sent have been acknowledged

Weight-throwing termination detection

Centralised basic algorithm, directed network.

Initiator has weight 1, noninitiators weight 0.

Problem with underflow, weight of process can become too small to be divided further

Safra’s algorithm

Decentralised basic algorithm and directed network.

Each process maintaines an integer counter, initially 0.

Processes colored white or black, initially white

Distributed garbage collection

processes provided with memory. objects carry pointers to local objects and references to remote objects

three operations by processes build or delete a reference

Reference counting

Tracks number of references to non-root object

Can be performed at runtime, but can’t reclaim cyclic garbage.

Indirect reference counting

Tree maintained for each object, with object at root, and references to this object as othe nodes in tree

If process receives reference, but already holds reference to or owns this object, it sends back decrement.

When duplicated/created reference has been deleted, and its counter is zero, decrement is sent to process it was duplicated from (or owner).

When counter of object becomes zero, and no pointers to it, object can be reclaimed.

Weighted reference counting

Each object carries total weight (weights of all references to the object) and a partial weight

If total weight of object becomes eequal to its partial weight, and no pointers to the object, it can be reclaimed.

Underflow problem – when weight of reference/object becomes too small to be divided further, no more duplicatation/creation possible

duplicated references are then to artificial object, so references to original object become indirect.

Garbage collection to termination detection

Garbage collection algorithms can be transformed into termination detection algorithms.

Given a basic algorithm. Let each process p host one artificial root object O(p). There is special non-root object Z.

Mark-scan

Two phases:

But in a distributed settings, mark-scan usually needs basic computation to freeze.

Mark-copy: second phase consists of copying all marked objects to empty memory space.

Mark-compact: second phase compacts all marked objects without requiring empty space.

Generational garbage collection

In practice, most objects either reclaimed shortly after creation, or stay accessible for very long time.

Garbage collection in Java divides object into two generations