Lesson 11 · Operating Systems

Distributed Operating Systems

Run one operating system across many computers so that users and programs see a single machine. Most of that promise can be kept. The part that cannot is hiding failure, because a machine that stops answering may be dead, cut off or just slow.

Distributed Operating Systems concept diagramA visual explanation of the layout and operations shown in this lesson.a distributed OS promises six transparencies — five are achievableaccessachievablelocationachievablemigrationachievablereplicationachievableconcurrencyachievablefailureprovably notaccess, location, migration, replication and concurrency are all routinely delivered todaya timeout cannot separate crashed from partitioned from merely slow — so failure can only be surfaced, never hidden
1

One System Built From Many Machines

  1. Access: local and remote resources use the same calls
  2. Location: a name does not say which machine holds the thing
  3. Migration: processes and data can move while in use
  4. Replication: several copies look like one
  5. Concurrency: many users share resources without coordinating by hand
  6. Failure: a crashed part does not show to the user

A distributed operating system runs on a group of independent computers, each with its own CPU and memory, connected by a network, and presents them as one computer. Users log in to the system rather than a machine, files have one namespace, processes have one table, and work is placed wherever there is spare capacity. That illusion is called a single-system image.

How well it works is measured as transparency: how much of the network the user and the programmer can ignore.

  • Machines share no memory and no clock; they only exchange messages
  • Transparency is the yardstick for every design
2

Distributed vs Network Operating System

The comparison courses ask for most is with a network operating system. In a network OS every machine runs its own full OS and the machines stay visible: you copy a file from a named server, log in to a named host, print to a named printer. A distributed OS removes the names of machines from the picture. A types of operating systems overview places both among the other kinds.

Network OS vs distributed OS
Network operating systemDistributed operating system
Each machine runsIts own complete OSOne OS spread across all machines
User seesSeparate machines, namedOne machine
Remote accessExplicit: server name, share, loginSame calls as local
Process placementWhere the user starts itChosen by the system, can migrate
ExamplesWindows Server file shares, NFSAmoeba, Sprite, Plan 9
  • Network OS: sharing between visible machines
  • Distributed OS: the machines disappear behind one system
3

Distributed Operating System Architecture

Most research designs put a small kernel on every node, often a microkernel that only handles memory, scheduling and message passing, and run everything else as servers that can live on any node: file servers, process servers, name servers. A program asks for a service by sending a message, and it does not need to know which node answers. This is the Amoeba and Mach model.

Machines are loosely coupled: no shared memory, no shared clock, only messages. So the OS has to rebuild, over the network, services a single machine gets for free. Remote procedure calls replace local calls, a naming service maps names to wherever things currently are, and a distributed file system serves one tree from many disks. Clocks are synchronised or replaced by logical ordering, and mutual exclusion and leader election become message protocols.

Course notes often add the overall shapes these systems take: client-server, where dedicated servers provide each service; peer-to-peer, where every node both serves and uses; and middleware, where ordinary OSes on each node are joined by a layer that supplies the shared view.

  • A kernel per node, services as servers anywhere
  • Message passing and RPC instead of shared memory
  • Naming, distributed files, clock sync, distributed locking and election
Implementation

Testing a distributed OS: the transparencies, then a silent node

class Account:
    def __init__(self):
        self.balance, self.seen = 100, set()

    def debit(self, amount, key):
        if key is not None and key in self.seen:
            return  # same request seen before: do not apply it twice
        if key is not None:
            self.seen.add(key)
        self.balance -= amount


def call(account, fault, key):
    if fault != "request lost":
        account.debit(10, key)  # the remote node did the work
    return "ok" if fault is None else "timeout"  # both faults look the same to the caller


for fault in (None, "request lost", "reply lost"):
    balances = []
    for key in (None, "tx-1"):
        account = Account()
        if call(account, fault, key) == "timeout":
            call(account, None, key)  # retry once; this time the network behaves
        balances.append(account.balance)
    print(f"{fault or 'no fault':<13} no key -> {balances[0]}, idempotency key -> {balances[1]}")
#include <cstdio>
#include <set>
#include <string>

struct Account {
    int balance = 100;
    std::set<std::string> seen;
    void debit(int amount, const std::string& key) {
        if (!key.empty() && !seen.insert(key).second) return;  // same request seen before: do not apply it twice
        balance -= amount;
    }
};

// fault: 0 none, 1 request lost, 2 reply lost
bool call(Account& account, int fault, const std::string& key) {
    if (fault != 1) account.debit(10, key);  // the remote node did the work
    return fault == 0;                       // both faults look the same to the caller
}

int main() {
    const char* names[] = {"no fault", "request lost", "reply lost"};
    for (int fault = 0; fault < 3; fault++) {
        int balances[2];
        std::string keys[] = {"", "tx-1"};
        for (int k = 0; k < 2; k++) {
            Account account;
            if (!call(account, fault, keys[k])) call(account, 0, keys[k]);  // retry once; this time the network behaves
            balances[k] = account.balance;
        }
        std::printf("%-13s no key -> %d, idempotency key -> %d\n", names[fault], balances[0], balances[1]);
    }
}
import java.util.HashSet;
import java.util.Set;

public class Main {
    static class Account {
        int balance = 100;
        Set<String> seen = new HashSet<>();

        void debit(int amount, String key) {
            if (key != null && !seen.add(key)) return;  // same request seen before: do not apply it twice
            balance -= amount;
        }
    }

    // fault: 0 none, 1 request lost, 2 reply lost
    static boolean call(Account account, int fault, String key) {
        if (fault != 1) account.debit(10, key);  // the remote node did the work
        return fault == 0;                       // both faults look the same to the caller
    }

    public static void main(String[] args) {
        String[] names = {"no fault", "request lost", "reply lost"};
        String[] keys = {null, "tx-1"};
        for (int fault = 0; fault < 3; fault++) {
            int[] balances = new int[2];
            for (int k = 0; k < 2; k++) {
                Account account = new Account();
                if (!call(account, fault, keys[k])) call(account, 0, keys[k]);  // retry once; this time the network behaves
                balances[k] = account.balance;
            }
            System.out.printf("%-13s no key -> %d, idempotency key -> %d%n", names[fault], balances[0], balances[1]);
        }
    }
}
Watch it run

Step through it

Running on nodes A, B, C · process 41 · /data/readings with 3 copies · node B goes silent at t = 4

what the user sees: one computernode ACPU, RAM, diskbusynode BCPU, RAM, diskidlenode CCPU, RAM, diskholds /data/readingsone namespace/data, /home, /binone process tablepids unique across nodesone CPU poolwork goes where there is roomthe goal: transparency, the network is invisible
Step 1

Three machines, one system

Nodes A, B and C each have their own CPU, memory and disk, joined only by a network. A distributed operating system tries to hide that: one file namespace, one process table, one pool of CPUs. A user logs in to 'the system', not to a machine. The next steps test that promise one transparency at a time.

Output
1 / 10
4

Why Partial Failure Is the Hard Part

In one computer a hardware failure usually stops the whole machine, and nobody is left wondering. In a distributed system one node can stop answering while the rest carry on. The caller sees only silence, and silence has three causes it cannot tell apart: the node crashed, the network cut it off, or it is alive but slow. Every timeout is wrong for one of them: too short and a slow node is declared dead while it is still working, too long and the system waits on a node that is gone.

Worse, a request may have run even though its reply was lost. Retrying then repeats the operation, and not retrying may lose it. That is why a remote call has three outcomes, success, failure and unknown, where a local call has two. Waldo and colleagues argued in 1994 that hiding remote calls behind a local-looking interface therefore cannot work. Keeping replicas consistent adds cost too: during a network split a system must choose between staying available and staying consistent, the trade the CAP theorem describes.

  • Crashed, cut off and slow all look the same
  • A lost reply makes retries dangerous unless repeats are harmless
  • Failure transparency is the goal that could not be met
5

Advantages and Disadvantages

The advantages and disadvantages of a distributed operating system come from the same fact: the machines are separate. That gives room to grow and survive failures, and it also brings the network's delays and uncertainty into everything.

  • Advantage: resource sharing, any program can use any machine's CPU, disk or devices
  • Advantage: scaling by adding machines rather than buying a bigger one
  • Advantage: reliability, work and data can survive one machine failing
  • Advantage: load balancing, idle machines take work from busy ones
  • Disadvantage: complexity, every service needs a network protocol
  • Disadvantage: partial failure and network delay are always present
  • Disadvantage: security, more machines and links to protect
  • Disadvantage: keeping copies consistent costs messages and time
6

Distributed Operating System Examples

The classic examples come from research. Amoeba, from Andrew Tanenbaum's group in Amsterdam, gave each user a pool of processors instead of a workstation; Python began as a scripting language for it. Mach at Carnegie Mellon built its message-passing microkernel with distribution in mind, and its descendant still sits inside macOS. Sprite at Berkeley moved running processes onto idle workstations. LOCUS at UCLA offered one file tree across machines. Plan 9 from Bell Labs made every resource a file in a per-process namespace served over its 9P protocol, and gave the world UTF-8.

None became a mainstream desktop OS, but the ideas spread. Linux namespaces, the basis of containers, echo Plan 9. Cluster systems such as Kubernetes place and restart work across thousands of machines, giving location and migration transparency without a shared kernel, while making failure explicit: a call can return UNAVAILABLE, and the program must cope. The tracer shows each transparency, then what one silent node does to them.

  • Research systems: Amoeba, Mach, Sprite, LOCUS, Plan 9
  • Today: clusters and orchestration deliver placement, not hidden failure