Models Many tasks that we would like to automate by using a computer are of question–answer type: we would like to ask a question and the computer should produce an answer. In
theoretical computer science, such tasks are called
computational problems. Formally, a computational problem consists of
instances together with a
solution for each instance. Instances are questions that we can ask, and solutions are desired answers to these questions. Theoretical computer science seeks to understand which computational problems can be solved by using a computer (
computability theory) and how efficiently (
computational complexity theory). Traditionally, it is said that a problem can be solved by using a computer if we can design an
algorithm that produces a correct solution for any given instance. Such an algorithm can be implemented as a
computer program that runs on a general-purpose computer: the program reads a problem instance from
input, performs some computation, and produces the solution as
output. Formalisms such as
random-access machines or
universal Turing machines can be used as abstract models of a sequential general-purpose computer executing such an algorithm. The field of concurrent and distributed computing studies similar questions in the case of either multiple computers, or a computer that executes a network of interacting processes: which computational problems can be solved in such a network and how efficiently? However, it is not at all obvious what is meant by "solving a problem" in the case of a concurrent or distributed system: for example, what is the task of the algorithm designer, and what is the concurrent or distributed equivalent of a sequential general-purpose computer? The discussion below focuses on the case of multiple computers, although many of the issues are the same for concurrent processes running on a single computer. Three viewpoints are commonly used: ; Parallel algorithms in shared-memory model • All processors have access to a shared memory. The algorithm designer chooses the program executed by each processor. • One theoretical model is the
parallel random-access machines (PRAM) that are used. However, the classical PRAM model assumes synchronous access to the shared memory. • Shared-memory programs can be extended to distributed systems if the underlying operating system encapsulates the communication between nodes and virtually unifies the memory across all individual systems. • A model that is closer to the behavior of real-world multiprocessor machines and takes into account the use of machine instructions, such as
Compare-and-swap (CAS), is that of
asynchronous shared memory. There is a wide body of work on this model, a summary of which can be found in the literature. ; Parallel algorithms in message-passing model • The algorithm designer chooses the structure of the network, as well as the program executed by each computer. • Models such as
Boolean circuits and
sorting networks are used. A Boolean circuit can be seen as a computer network: each gate is a computer that runs an extremely simple computer program. Similarly, a sorting network can be seen as a computer network: each comparator is a computer. ; Distributed algorithms in message-passing model • The algorithm designer only chooses the computer program. All computers run the same program. The system must work correctly regardless of the structure of the network. • A commonly used model is a
graph with one
finite-state machine per node. In the case of distributed algorithms, computational problems are typically related to graphs. Often the graph that describes the structure of the computer network
is the problem instance. This is illustrated in the following example.
An example Consider the computational problem of finding a coloring of a given graph
G. Different fields might take the following approaches: ; Centralized algorithms was originally presented as a parallel algorithm, but the same technique can also be used directly as a distributed algorithm. Moreover, a parallel algorithm can be implemented either in a parallel system (using shared memory) or in a distributed system (using message passing). The traditional boundary between parallel and distributed algorithms (choose a suitable network vs. run in any given network) does not lie in the same place as the boundary between parallel and distributed systems (shared memory vs. message passing).
Complexity measures In parallel algorithms, yet another resource in addition to time and space is the number of computers. Indeed, often there is a trade-off between the running time and the number of computers: the problem can be solved faster if there are more computers running in parallel (see
speedup). If a decision problem can be solved in
polylogarithmic time by using a polynomial number of processors, then the problem is said to be in the class
NC. The class NC can be defined equally well by using the PRAM formalism or Boolean circuits—PRAM machines can simulate Boolean circuits efficiently and vice versa. In the analysis of distributed algorithms, more attention is usually paid on communication operations than computational steps. Perhaps the simplest model of distributed computing is a synchronous system where all nodes operate in a lockstep fashion. This model is commonly known as the LOCAL model. During each
communication round, all nodes in parallel (1) receive the latest messages from their neighbours, (2) perform arbitrary local computation, and (3) send new messages to their neighbors. In such systems, a central complexity measure is the number of synchronous communication rounds required to complete the task. This complexity measure is closely related to the
diameter of the network. Let
D be the diameter of the network. On the one hand, any computable problem can be solved trivially in a synchronous distributed system in approximately 2
D communication rounds: simply gather all information in one location (
D rounds), solve the problem, and inform each node about the solution (
D rounds). On the other hand, if the running time of the algorithm is much smaller than
D communication rounds, then the nodes in the network must produce their output without having the possibility to obtain information about distant parts of the network. In other words, the nodes must make globally consistent decisions based on information that is available in their
local D-neighbourhood. Many distributed algorithms are known with the running time much smaller than
D rounds, and understanding which problems can be solved by such algorithms is one of the central research questions of the field. Typically an algorithm which solves a problem in polylogarithmic time in the network size is considered efficient in this model. Another commonly used measure is the total number of bits transmitted in the network (cf.
communication complexity). The features of this concept are typically captured with the CONGEST(B) model, which is similarly defined as the LOCAL model, but where single messages can only contain B bits.
Other problems Traditional computational problems take the perspective that the user asks a question, a computer (or a distributed system) processes the question, then produces an answer and stops. However, there are also problems where the system is required not to stop, including the
dining philosophers problem and other similar
mutual exclusion problems. In these problems, the distributed system is supposed to continuously coordinate the use of shared resources so that no conflicts or
deadlocks occur. There are also fundamental challenges that are unique to distributed computing, for example those related to
fault-tolerance. Examples of related problems include
consensus problems,
Byzantine fault tolerance, and
self-stabilisation. Much research is also focused on understanding the
asynchronous nature of distributed systems: •
Synchronizers can be used to run synchronous algorithms in asynchronous systems. •
Logical clocks provide a causal
happened-before ordering of events. •
Clock synchronization algorithms provide globally consistent physical time stamps. Note that in distributed systems,
latency should be measured through "99th percentile" because "median" and "average" can be misleading. ===
Election===
Coordinator election (or
leader election) is the process of designating a single
process as the organizer of some task distributed among several computers (nodes). Before the task is begun, all network nodes are either unaware which node will serve as the "coordinator" (or leader) of the task, or unable to communicate with the current coordinator. After a coordinator election algorithm has been run, however, each node throughout the network recognizes a particular, unique node as the task coordinator. The network nodes communicate among themselves in order to decide which of them will get into the "coordinator" state. For that, they need some method in order to break the symmetry among them. For example, if each node has unique and comparable identities, then the nodes can compare their identities, and decide that the node with the highest identity is the coordinator. Coordinator election algorithms are designed to be economical in terms of total
bytes transmitted, and time. The algorithm suggested by Gallager, Humblet, and Spira for general undirected graphs has had a strong impact on the design of distributed algorithms in general, and won the
Dijkstra Prize for an influential paper in distributed computing. Many other algorithms were suggested for different kinds of network
graphs, such as undirected rings, unidirectional rings, complete graphs, grids, directed Euler graphs, and others. A general method that decouples the issue of the graph family from the design of the coordinator election algorithm was suggested by Korach, Kutten, and Moran. In order to perform coordination, distributed systems employ the concept of coordinators. The coordinator election problem is to choose a process from among a group of processes on different processors in a distributed system to act as the central coordinator. Several central coordinator election algorithms exist.
Properties of distributed systems So far the focus has been on
designing a distributed system that solves a given problem. A complementary research problem is
studying the properties of a given distributed system. The
halting problem is an analogous example from the field of centralised computation: we are given a computer program and the task is to decide whether it halts or runs forever. The halting problem is
undecidable in the general case, and naturally understanding the behaviour of a computer network is at least as hard as understanding the behaviour of one computer. However, there are many interesting special cases that are decidable. In particular, it is possible to reason about the behaviour of a network of finite-state machines. One example is telling whether a given network of interacting (asynchronous and non-deterministic) finite-state machines can reach a deadlock. This problem is
PSPACE-complete, i.e., it is decidable, but not likely that there is an efficient (centralised, parallel or distributed) algorithm that solves the problem in the case of large networks.
Other Topics Linearizability ==See also==