Programming Paradigms Session 8 · Notes

← Session 8, Message Passing

Session 8 · lecture notes, block 1

Block 1: Determinism, choice and buffer capacity

Lecture notes of block 1, session 8, Message passing, 4 November 2026. Every program on this page was run while the session was prepared and its output recorded; what is shown is one sample of a run.

1. The RC 4000 nucleus, Copenhagen, 1969

The story begins in Copenhagen, with the earliest message-based system of the session: a computer of 1967 whose multiprogramming system, finished in 1969, made messages the basic means of communication between its processes1. It predates Kahn's networks, CSP and the actor model.

The computer was Regnecentralen's RC 40001. Its first prototype monitored temperatures and pressures at an ammonia plant at Puławy in Poland, designed by the engineering firm Haldor Topsøe2. The prototype also counted how many kilos of fertilizer left the plant each day2. Politiken names the leader of the group building its multiprogramming system: Per Brinch Hansen, aged 302.

The nucleus the group built is the reason the machine is in the story. Brinch Hansen's team did not write a conventional operating system. They wrote a small nucleus with three jobs, in the paper's words: the simulation of processes, communication among processes, and the creation, control and removal of processes3. Messages were its basic means of communication between processes. Operating systems and user programs ran on top as ordinary processes; device handling and process control stayed inside the nucleus3. The paper appeared in Communications of the ACM in April 1970 as "The Nucleus of a Multiprogramming System"3. The nucleus was small, 4,800 words, or 6,200 with the basic operating system; a send took 0.6 ms, a wait 0.4 ms, a full conversation about 2 ms3. The RC 4000 was not widely used, and it is an early published microkernel design. The idea of a minimal kernel in which processes communicate only by messages is commonly read as the start of the microkernel line. The line's best-known later members are Mach (CMU, from 1985) and L4 (Liedtke, 1993 to 1995); no source opened draws the line from the nucleus to either by name.

The choice of messages was deliberate. Brinch Hansen had learned synchronization from Dijkstra's Cooperating Sequential Processes, the manuscript that made semaphores widely known4: Brinch Hansen's reference list dates the manuscript September 1965, and it was printed in 1968. The 1970 paper acknowledges it: "we have benefited greatly from Dijkstra's analysis of cooperating sequential processes"3. Having learned semaphores, he chose not to hand them to processes. He gave them messages instead, and the paper says why. The semaphore concept alone "does not fulfill our requirements of safety and efficiency in a dynamic environment in which some processes may turn out to be black sheep and break the rules of the game"3.

What a message buys against shared memory is the problem of the lecture. The machine returns first to show where its shared memory went (section 3), then to show that it uses two of the session's three resolutions at once (section 6). It returns again wherever a later system reuses one of its ideas.


2. Shared memory and the scheduler

When threads share memory, the scheduler decides how their steps interleave, and any conflicting, unordered access to shared data can change the result; the program text does not mark where that can happen.

Session 7 ended with threads, locks, monitors and linearizability. What threads share is memory. Two threads may read and write the same variable, and the scheduler decides how their steps interleave.

// two threads run this at once, starting from balance = 100
int b = balance;      // both may read 100
balance = b + 50;     // both write 150: one deposit is lost

The same loss happens to a counter of page views that many requests increment without a lock. Four Java threads that each added one to a shared field 250,000 times left it at 473,696, 505,178 and 450,955 in three runs. Each was below the 1,000,000 expected, and nothing reported an error. With a lock, or an AtomicInteger, the count was 1,000,000 every time (run: extra/0b/LostUpdate.java). The same counter returns in section 9, as a process of its own, and loses an increment there too. Every shared variable is a place where threads may compete. If two threads touch it, at least one writes, and nothing orders the two accesses, the result can depend on timing. Locks restore order, but only if every access remembers to take them. One forgotten lock, on data another thread writes with nothing else ordering the two accesses, is a data race. Two locks taken in opposite orders by two threads can deadlock. The lost deposit above is one interleaving of the two threads' steps, and the interleaving picture is a model, not the whole truth. A program with a data race is undefined in C and C++5,6. In Java a racy read returns a value some write produced, except a plain long or double, whose two halves may come from different writes7. The memory model's happens-before and causality rules still constrain which writes that read may see7. In Go a read of a word-sized location sees some write to it. A race on a multiword value (an interface, a slice, a string, a map) can give a torn value and corrupt memory, and an implementation may report the race and stop the program6. Every one of these models allows the interleavings and some allow more, so the lecture reasons in the interleaving model and says so.

thread Athread Bint b = balance;balance = b + 50;int b = balance;balance = b + 50;balance100150100100150150200150150150150200

Two threads deposit 50 each into one balance. Between any two instructions the scheduler may switch threads, and the program text marks none of these points; a schedule is one line woven through the two columns. In the interleaving model, four of the six schedules lose a deposit.

  1. Each thread will read the balance into its own b, then write b + 50; the balance is 100.
  2. The marks between the instructions are the points where the scheduler may switch threads: all of them, since nothing in the text says which matter.
  3. One schedule: thread A reads 100.
  4. Thread B reads 100 too, before A has written.
  5. Thread A writes 150.
  6. Thread B writes 150 over it: A's deposit is lost.
  7. All six schedules of the four instructions: two end at 200, four at 150.

Two cooks sharing one cutting board are the picture that holds. They are truly simultaneous, so they must take turns, which is the lock; if one forgets, their knives collide, which is the data race. The board is the shared memory, and every cut is a place where a collision is possible.

A program is deterministic when every run on the same input data gives the same observable results. It is nondeterministic when the same input can give different results, depending on choices the program text does not fix, here the scheduler's. A clock or a random draw counts not as input but as a source of nondeterminism (section 5). The word applies to two things that must be kept apart: the execution, which steps run in which order, can differ from run to run while the result stays the same. Unless the execution is named, nondeterminism in this lecture means a difference in the result. A run that stops early and produces a prefix of another run's results differs from it in liveness, which section 8 counts as waiting or deadlock, not in its values. The definition is Kahn's in another form: a network is determinate when the histories on its channels depend only on its inputs8,9.

The useful way to describe this is not "shared memory is hard". It is this: in a shared-memory program, nondeterminism can enter at any conflicting, unordered access to shared data, and nothing in the program text marks which accesses those are. The scheduler makes the choice, everywhere, all the time. That holds in a language whose types do not require shared data to be marked, as Java, C and Go do not; Rust's types do, which section 12 returns to. Hoare put the hardware side of the same complaint in 1978: processors that cooperate by "inspection and updating of a common store" can create severe problems for writing correct programs10. That cooperation, he added, may be expensive and unreliable in some technologies of hardware implementation10. Section 5 says where, once nothing is shared, nondeterminism can still enter.


3. Processes that share nothing, and the shared memory inside the runtime

The first move of message passing is to stop sharing: each process owns its data and can affect another only by sending it a value. The gain is that nondeterminism is fenced into a few visible places, the points where processes meet. What the move hides is that on one machine the shared memory does not disappear but moves into the runtime, into one trusted place, which the RC 4000 shows exactly.

If the scheduler can choose at any conflicting, unordered access to shared data, and the text does not mark which accesses those are, the first remedy is to take the shared data away. That is the first move of message passing: stop sharing. Each process owns its data. The only way to affect another process is to send it a value. Andrews and Schneider put it in one line: processes send and receive messages instead of reading and writing shared variables11. Synchronization, in their account, follows from the fact that a message can be received only after it has been sent11.

The gain is precise. The move fences nondeterminism into a few visible places. Inside a process that reads no clock, draws no random numbers, takes no other outside input and uses no construct whose order the language leaves open (Go's iteration over a map is one), code is sequential and deterministic. Timing can matter only where processes meet, at communications, as long as what is sent is a value and not a pointer to memory both sides still use, which Go permits and section 12 shows. In the kitchen: each cook gets a board of their own, and the only way to pass a thing is to hand it over. Timing can now matter only at the handover.

The shared memory inside the runtime

Students often hear "message passing has no shared memory". That is true of the message exchange in the programming model and, on one node, false of the machine; across machines, or over the links of a transputer, there is no shared memory to hide. The RC 4000 shows exactly where the sharing went on one node. The nucleus kept a common pool of message buffers and one queue per process3. A send went like this:

  1. The nucleus takes a free buffer from the pool.
  2. It copies the message from the sender's memory into the buffer.
  3. It links the buffer into the receiver's queue.

The receiver later copies the message out into its own memory. In a message exchange neither process touches the other's memory: the nucleus copies in and out; the machine's process model still let a parent's storage contain its children's3. Both processes, however, touch the pool and the queues, through the nucleus. That is shared memory: the post office's sorting room, which no customer enters, but through which every letter passes.

The paper says how the nucleus protected it. "The communication primitives are executed in the uninterruptable mode within the system nucleus"3. The hardware disabled interrupts on entry to the interrupt program12. On a single processor, which the paper implies and does not state, nothing else can run while interrupts are off. If every communication primitive ran with interrupts off up to its completion or up to the point where it suspended its caller, and no device wrote the pool or the queues meanwhile, that is in effect one global lock around the nucleus's message handling. Process creation and removal ran in an interruptible process inside the nucleus3. In the lab, the warm-up's nucleus is built on exactly that one lock.

process Aprocess Bnucleusmmpoolqueue of Bmmbuf = b1mbuf = b1
-- process Abuf := send message(B, m) -- process B(sender, m, buf) := wait message()

What message passing hides, drawn as a section through the RC 4000: the programming model above the floor, the nucleus under it. A message is copied from the sender's memory into a buffer from a common pool, linked into the receiver's queue, and copied out again; the pool and the queues are shared, reached only through the primitives.

  1. The programming model: two processes, each with its own memory; A holds a message m.
  2. In the model, m goes from A to B, and A keeps its own copy.
  3. The cut through the floor shows what the model hides: the nucleus, with a pool of buffers and one queue per process.
  4. Send message: the nucleus takes a free buffer from the pool.
  5. It copies m from A's memory into the buffer.
  6. It links the buffer, b1, at the tail of B's queue, and send message returns its identity to A.
  7. Wait message: the nucleus takes b1 from B's queue and gives B a second copy of m, with the sender and b1's identity; b1 stays out of the pool, held for the answer.
  8. The send and the wait both went through the nucleus to the pool and the queue: the shared memory is still there, in one place. On the single processor the paper implies, a primitive runs with interrupts off, so in effect one lock guards that place.

The same holds today. A Go channel is a runtime structure, hchan, with a buffer, queues of waiting goroutines, and a lock13; that is the runtime of go1.27, not the specification, which says nothing of locks14. An Erlang mailbox is a queue managed by the virtual machine.

Message passing on one node does not remove shared memory; it hides it in one trusted place, which only has to be right once, as long as messages carry values and not shared pointers.

That place is small, and someone else wrote it. The move has a cost all the same: waiting replaces racing.


4. Kahn process networks: determinism without choice

Once processes share nothing, timing can matter only where they meet, and the gain is sharpest where no meeting point is ever contested. Kahn's networks of 1974 are the case in which none is: they are deterministic by construction.

In 1974, Kahn described processes connected by FIFO channels8,10 (cited by Hoare 1978 as reference [12]). Each process is a sequential, deterministic program, whose outputs depend only on the values it has read; each channel has exactly one writer and, in the form this lecture keeps, one reader. A write never waits; the channel is an unbounded queue. A read names one channel and waits until a value is there. A process cannot ask "is there something on this channel?" and cannot wait on "whichever channel is ready first".

Kahn's own rule is weaker on the reading side: a channel has one writer, and several processes may read it, each receiving every value10,15. This lecture keeps one reader per channel and loses nothing by it. A channel read by several processes behaves as a process that reads the channel and writes each value to one channel per reader. That copying process is sequential and deterministic, so the network is still a Kahn network and computes the same histories. Run on Go channels at capacities 0, 1 and 100, two readers behind a copying process received all twelve values, in order, in every one of 400 runs at each capacity. Two readers taking from one channel instead shared the values out in 31 to 77 different ways at GOMAXPROCS 12, and in one way at GOMAXPROCS 1 (run: extra/0b/fanout_split.go). The copy is therefore not a split: in a split, several readers consume one channel and each value reaches one of them, which section 5 counts among the ways nondeterminism enters9. With bounded channels the copying process ties the readers' pace together, a reader that stops reading holding up the other; that changes the waiting and never the values (section 8, point 1).

Kahn's result is determinism: under any fair schedule, the network computes the same sequences on its channels8,9. The reason has two parts. First, because reads block and nothing tests for emptiness, each process computes a continuous, hence monotone, function of its input histories8,9. Such a function is what Kahn's fixed-point argument needs, and sequential processes with blocking reads compute one8,9. Second, no two processes ever compete for the same communication. So under any fair schedule, one in which every process that can run eventually does, the network computes the same sequences; an unfair schedule computes a prefix of them. Timing can change when things happen but never what happens. Drop either part and determinism is no longer guaranteed; section 5 lists the ways it can go. An assembly line is the picture: each station takes from the belt before it and puts on the belt after it. However fast or slow each worker is, the parts come out in the same order with the same work done.

Two senders and one receiver, with and without a contest

The difference between a contested meeting point and an uncontested one fits in four lines of Go, first with competition. Two goroutines send to one channel, and the main goroutine prints what arrives:

hello_loop.go, the lines shown
c := make(chan string)
go func() { c <- "hello" }()
go func() { c <- "world" }()
fmt.Println(<-c, <-c)    // "hello world" or "world hello"

Same code, two possible outputs. The two senders compete for the receiver, and the scheduler settles it. In practice one order dominates. In 3,000 iterations with go1.27.1, "hello world" appeared 0 times at GOMAXPROCS 1, 10 times at 2 and 3 times at 12 (run: blocks/hello_loop.go). An earlier run had printed "world hello" 3,000 times out of 3,000 (go1.24.7, GOMAXPROCS 1 and 2). For the lecture, the program runs in a loop with GOMAXPROCS at least 2, and the outcomes are counted before both are shown. The reliable demonstration of two outcomes is a select whose two cases are both ready when it runs, for instance two channels of capacity 1 filled before it. The demonstration is reliable because the specification states that this choice is uniform and pseudo-random14. A select fed by two freshly started goroutines inherits the scheduler's bias, and the two-sender merge is the measured case, its bias the runtime's.

A second version follows Kahn's discipline, one writer, one reader and no choice, on Go channels. Each sender gets its own channel, and the receiver names which channel to read. Unlike Kahn's, these writes block; that can stop a network early, so its output can be cut short, but every value it does produce is the one the unbounded network produces.

a, b := make(chan string), make(chan string)
go func() { a <- "hello" }()
go func() { b <- "world" }()
fmt.Println(<-a, <-b)    // always "hello world"

The output never changes. The price is visible too: if the "hello" goroutine is slow, main waits on a even though "world" is already waiting on b.

sender 1mainsender 2cabsender 1mainsender 2cab"world""world""hello""hello"world hello2,990 of 3,000 runs at GOMAXPROCS 2"hello""hello""world""world"hello world10 of 3,000 runs at GOMAXPROCS 2"hello""hello""world""world""hello""hello""world""world"hello worldhello worldevery runevery runwith one channel c the same senders print world hello or hello world
c := make(chan string)go func() { c <- "hello" }()go func() { c <- "world" }()fmt.Println(<-c, <-c)a := make(chan string)b := make(chan string)go func() { a <- "hello" }()go func() { b <- "world" }()fmt.Println(<-a, <-b)

hello_loop.go, the one-channel program, go1.27.1, 3,000 runs each: "hello world" 0, 10 and 3 times at GOMAXPROCS 1, 2 and 12

Two senders and one receiver on an unbuffered channel, two runs side by side, each one possible schedule. A dot marks a goroutine reaching its send, a dotted stretch of a lane is that goroutine waiting, and a horizontal arrow is a handshake, sender and receiver meeting at one instant. With one channel the runs print different things; with one channel per sender they wait differently and print the same.

  1. The program: two goroutines send on one channel c, and main receives twice.
  2. One run: world is received first and printed first; sender 1 waits until main receives again. This is the order nearly every run shows.
  3. Another run: hello first, and the output changes. With go1.27.1 at GOMAXPROCS 2 it happened 10 times in 3,000; the specification leaves the order among senders open.
  4. One channel per sender, main reading a then b: in one run main waits on a (in orange) while world already waits on b; in the other, world waits. The waiting differs, the output never does.

That is the whole trade-off of the session in one picture: a contested communication buys responsiveness and costs determinism; no contest keeps determinism and costs waiting. Here the contest is a merge, two writers on one channel. A guarded choice in the program is the other way to let a contest in, and section 5 names both. In the lab, part 1 runs this program on one queue under both disciplines.

The cost is a possibility, not a necessity: a program may use a choice whose branches lead to the same result. The result then stays deterministic, in the sense of the same observable results, although the execution is not. Equally, a network without choice waits needlessly only where the channel it reads is empty while another is not.

Kahn networks are not exotic. A plain shell pipeline, grep x | sort | uniq, is one. Each program is a deterministic program that reads one input and writes one output. For the same input in the same environment, it therefore gives the same answer every time. Its pipes are bounded buffers, unlike Kahn's unbounded queues, so a network of pipes can stall where Kahn's cannot. It can stall on a cycle, on paths that fork and rejoin, or where a live reader stops reading before its writer stops writing. A straight pipeline that drains only waits. A reader that exits instead ends its writer, whose next write fails with EPIPE and raises SIGPIPE16. Either way the pipeline never prints something different (section 8). The command lines below show each case on the lecture machine. Unix pipes are documented in the Third Edition manual of February 1973, whose page pipe(II) is dated 15 January 197317, and Ritchie dates the implementation to 197218.

The idea is older than the system call. McIlroy's memo of 11 October 1964 asks for "some ways of coupling programs like garden hose"19. Conway's coroutines of 1963 already chained the stages of a compiler inside one program, each module "an autonomous program which communicates with adjacent modules as if they were input or output subroutines"20. Pipes thus ran before Kahn gave networks of this shape a theory in 1974. Kahn's paper cites neither Unix nor Conway8; Kahn and MacQueen's report of 1976 cites both, the Unix "pipelining combinator" and "Conway's original concept of coroutines"15. The time-sharing systems and the networks of machines that led towards the story without belonging to its theory are in appendix J.

Choice among inputs arrived in Unix later, with the select system call, distributed in 4.1cBSD in April 1983 and released with 4.2BSD in August 198321,22,23. The call came as part of the interprocess communication Berkeley built for networks; the sockets of that interprocess communication replaced the multiplexed files of Version 724. select reports which descriptors are ready, and the program then performs the read25; a guard of CSP performs the communication it waits for (section 7). A network of the same kind in Go is the prime sieve, a pipeline of goroutines with one filter per prime:

sieve.go, the lines shown
func generate(out chan<- int) {
    for i := 2; ; i++ {
        out <- i
    }
}

func filter(in <-chan int, out chan<- int, p int) {
    for {
        n := <-in
        if n%p != 0 {
            out <- n
        }
    }
}

func main() {
    ch := make(chan int)
    go generate(ch)
    for i := 0; i < 10; i++ {
        p := <-ch
        fmt.Println(p)
        next := make(chan int)
        go filter(ch, next, p)
        ch = next
    }
}

Every channel has one writer and, at any moment, one reader: main takes one value from ch and only then starts the filter that reads it next. The two readers are therefore ordered by the program text and never concurrent. With one writer and one reader per channel at any moment, the printed primes never change order whatever the scheduling. The stages wait on each other, which is the price named above.

Unix pipelines as Kahn networks on the lecture machine

Eight command lines, run on the lecture machine, show the model at work and where pipes depart from it.

seq 1 100000 | grep 7 | sort -r | head -5
seq 5 | while read x; do sleep 0.$RANDOM; echo $x; done | awk '{print $1*$1}'
printf 'b\nZ\na\nB\nA\n' | LC_ALL=C sort
printf 'b\nZ\na\nB\nA\n' | LC_ALL=en_US.UTF-8 sort
(dd if=/dev/zero bs=1k count=200 2>/dev/null; echo 'writer done' >&2) | (sleep 3; wc -c)
yes | head -3
rm -f f; mkfifo f; seq 1 200000 | tee f | paste - <(tail -r f)
{ (sleep 0.0$RANDOM; echo hello) & (sleep 0.0$RANDOM; echo world) & wait; } | cat
  • The first printed the same five lines in 53 runs.
  • The second took between 1.35 and 2.38 seconds and printed 1 4 9 16 25 every time: a slow stage changes when, not what.
  • The third and the fourth sorted the same five lines in two orders, A B Z a b and a A b B Z: the environment is an input.
  • The fifth shows that a pipe is bounded. The pipe holds 65,536 bytes on this machine, so the writer of 200 KiB finishes only after the reader wakes, at 3.02 seconds; a writer of 64 KiB finishes at once.
  • The sixth prints three lines; yes then ends, killed by SIGPIPE16, and the shell reports status 141 (run). The reader stopped early, which cut the output short and changed none of it.
  • The seventh is a fork that rejoins: tee writes every line to paste and to the named pipe f, and tail -r (tac on GNU systems) writes nothing before its input ends. With 10 lines it completes; with 200,000 it stalls: tee waits for paste to take more, paste waits for its first line from tail, and tail waits for the end of f, which tee holds open. It completed in every try up to 73,728 bytes of input and stalled in every try from 108,894 bytes, and in some tries between. An unbounded network would finish.
  • The last puts two writers on one pipe, without any select: in 20 runs, 14 printed hello world and 6 world hello. It is a merge, several writers on one channel, the first way out of Kahn's conditions that section 5 names.

The runs are on record under demos/extra/0b/ (pipelines.sh, pipe_capacity.py, pipe_fill.sh, fork_rejoin.sh, each with its .run.txt).

The limits of a deterministic network

The absence of choice costs something besides waiting. A deterministic network cannot:

  • serve whichever client asks first;
  • give up after a timeout;
  • react to whichever of two events happens first.

Are these limits missing features, or the cost of determinism? Each of the three is a decision that depends on timing, and a Kahn process cannot take one. To read, a process names one channel and waits until a value is there. It "cannot be waiting on data coming from one or another of its input lines"8, and the availability of a value "cannot be tested"15. A server with two clients must therefore name one client's channel. If that client is silent, the server waits, as main waits on a in the hello world above, although the other client has already asked. The order of service is fixed by the program text and the values read, never by who asked first. A timeout means that nothing arrived by a time t, and observing that nothing arrived is the test for emptiness the model forbids9. A process that reads a clock and sends the time on a channel does not help, because the reading process still names the channel it reads next by its program text and the values it has read, never by what has arrived. Reacting to whichever of two events happens first is the waiting form of the same test. A network can act on a timeout or an arbitration only when some process supplies it as a value on a channel. That process, which reads a clock or merges two inputs, is then the source of nondeterminism itself (section 5).

The reason underneath lies in what a process may depend on. Its outputs are a function of the histories of its inputs, the sequences of values on its channels8. A history records the values and their order, not the times at which they arrived. Kahn and MacQueen excluded "time-dependent input/output behaviour" on purpose15. Which of two channels received a value first is in no history, so no decision can be written on it. The three limits are therefore not missing features; they are what determinism costs. A merge that takes from whichever input has a value is accordingly not a Kahn process: a nondeterminate merge "must be either unfair or nonmonotonic, and hence not continuous"9.

Real systems need all three, so competition has to be let back in. Kahn's network is the reference point of what follows: each system the rest of the lecture reads is described by the conditions of Kahn's that it gives up, and by what it gains for them. The whole session turns on how a contested communication is resolved.


5. Contested communications: where nondeterminism enters, and three resolutions

A communication is contested when more than one party may be taken next at the same point. Where the program text does not decide which party is taken next, something other than the text decides it: the language's selection among the ready partners, the scheduler, the runtime, or the order of arrival. The systems of this story resolve a contested communication in one of three ways. The list classifies them and is not exhaustive (a split, several receivers on one Go channel, is resolved by the runtime's queue of waiting receivers, which the specification leaves open):

  • No contest. One writer and one reader per channel, and no choice: Kahn's network. The result is deterministic, and the price is waiting.
  • A guarded choice in the program. The program marks a point where it takes whichever of several partners is ready, and the language selects among those ready there: Hoare's guarded commands and Go's select. This is the channel family. Section 7 compares Kahn's networks with CSP, which has this construct.
  • Arrival order in a queue. Many senders put messages into one queue, and the order of arrival determines which is served first: the RC 4000's queues, actors, Erlang. This is the mailbox family. The order of arrival is the free variable. The actor model leaves it arbitrary, and Erlang fixes it per pair of sender and receiver. An Erlang receiver may then select among the arrived messages by pattern.

The kitchen of section 2 shows the three. With no contest, the cook at the pass takes plates from the hatches in an order fixed by the recipe: the next plate is never in doubt. If the next hatch is empty, the cook waits, although another hatch already holds a plate. With a guarded choice, the cook watches two hatches and takes from whichever has a plate: the choice is made at one visible place. With arrival order, the tickets pinned on a cook's spike are cooked in the order they were pinned (section 9), and which ticket was pinned first depends on when the waiters came.

Each later section says which resolution its systems use, and the one machine of 1969 turns out to use two of them at once by default.

no contestKahn networksPQR<-a, then <-bab12pqone outcome: p, then qguarded choiceCSP, Go selectPQRselect on a and babpqq first here; p first in another runarrival orderRC 4000, actors, ErlangPQRreceive Msg ->qpfrontq first here: it arrived first

Two senders, P and Q, and one receiver, R, drawn three times on one scaffold; the drawings differ in one element, the one that resolves a contest for R, and the steps send the same two messages through each, q sent first. The three classify the systems of this session; they are not a taxonomy of message passing.

  1. P and Q each have a message for R; q is sent first.
  2. No contest: one channel per sender, and R reads a, then b. q, sent first, waits on b; there is one outcome, p then q, at the price of that wait.
  3. A guarded choice: R takes a partner that is ready. Here q is ready first and is taken; in a run where both are ready, Go takes one by a uniform pseudo-random selection, so p can come first: two outcomes.
  4. Arrival order: both messages go into R's queue, and R takes them from the front. q arrived first and is served first; another run can bring p first: two outcomes.

In a program whose processes share nothing by any other route, whose messages carry values and whose runtime delivers them as section 11 assumes, nondeterminism can enter only where several parties compete for one communication point, where a process tests whether a communication is possible, or inside a process. A contest allows a different outcome and does not force one. Lee and Parks list five ways to add nondeterminism to a Kahn network: testing inputs for emptiness, internally nondeterminate processes, several writers on a channel, several readers on a channel, and shared variables9. Message passing removes the shared variables. Of the remaining four, three are communication points (several writers, several readers, a test for emptiness), and one, a process that is nondeterminate inside itself (a clock, a random draw), no model removes. A language adds a fourth communication point, the guarded choice, a test of which input is ready. The four communication points:

  • many senders into one receiver, a merge;
  • many receivers on one channel, a split;
  • a choice the programmer writes among alternatives, a guard that asks which input is ready;
  • a test for emptiness, asking whether a message is there without waiting for it (Go's select with default or len of a channel, Erlang's receive … after 0).

None of this is about receive versus send: two goroutines reading one Go channel compete as much as two writing to it. Kahn's network, in the course's form, rules out all four by giving every channel one writer and one reader and forbidding choice and tests for emptiness. The three resolutions are what each family makes its default, not the limits of what it can express. Go has merges, and Erlang's selective receive is a guarded choice over the messages already merged into the mailbox.

Beside the resolution of contested communications, a model has to settle five other things, each met once in what follows. They are what a send names (a process, a channel, a mailbox); whether the sender waits; which order is kept; whether a message can be lost; and what happens when a partner dies. The survey of Andrews and Schneider classifies models by the first two11. The last three concern a message after its send and a partner after its death. The last of them is exact on one node whose runtime tracks the death of its processes, as Erlang's and the RC 4000's do and Go's does not. Session 9 takes up the death of a partner in full.


6. The RC 4000 nucleus: two resolutions in one machine

With the three resolutions named, the machine of section 1 can be read properly.

The 1970 paper names four primitives3:

client:                                server:
  buf := send message(server, m)         loop
      -- returns at once                    (sender, m, buf) := wait message()
  ...other work...                          ...serve m...
  answer := wait answer(buf)                send answer(buf, result)

One conversation runs as follows. The client calls send message, naming the server. Within its limit of outstanding messages, the call returns at once with the identity of the buffer used3 (what happens beyond the limit is not on record). The client goes on with other work3. The server waits in wait message until a message is in its queue, and receives the sender's name, the message and the buffer3. It serves the request and calls send answer, which copies the answer into the same buffer; the server continues at once3. The client calls wait answer on its buffer and waits until the answer is there; the buffer then goes back to the pool3. In the lab, the warm-up is a toy of this nucleus with these four names, the holes in send message and wait message, and that is where the primitives are first met in full.

Requests: a send names a process, which has one queue, and messages from every sender land in it in arrival order3. The primitive wait message serves them first come, first served, and two further primitives let a process serve its queue in any order3. Within its limit of outstanding messages, the sender does not wait. When several clients compete for one server, arrival order in the queue resolves the contest through wait message. This is the mailbox family's resolution, four years before Hewitt's actors.

Replies: the answer travels back in the same buffer, delivered into the client's queue, and the client waits for that buffer by its identity3. The paper calls the choice of a buffer "the creation of an identification of a conversation"3. The nucleus stores the identity of sender and receiver in each buffer and checks it whenever a process sends or waits for an answer in that buffer. In this way, no third process can interfere with a conversation3. Nobody competes for a reply, because the client waits for one identified item and not for the next thing in its queue. Here the no-contest resolution of section 5 is obtained by identifying the conversation rather than by wiring one channel to one reader. The same idea returns as Go's reply channel carried in the request (section 7) and as Erlang's reference matched by a selective receive (section 9). One difference remains: the nucleus checks the identity, where Go's and Erlang's programs keep it by convention. In the kitchen, a request is a ticket on the spike, cooked in the order pinned. The reply is the plate marked with the table's number: the waiter waits for that plate, not for the next one that comes out.

client Cprocess Dserver Snucleuspoolqueue of Cqueue of Sbuf = b7ddxb7 · mmb7 · rrb7
-- client Cbuf := send message(S, m)  ...other work...answer := wait answer(buf) -- server S, in a loop(sender, m, buf) := wait message()send answer(buf, result)

One conversation on the RC 4000, on the same section, and the two resolutions of one machine: requests meet in the server's queue and are served in arrival order; the answer comes back in the same buffer, b7, into the client's queue, where the client takes it by its identity, so nobody competes for the reply. Buffers stay in the nucleus; only copies cross the floor.

  1. Process D has already sent d to the server; the buffer holding d waits at the head of S's queue.
  2. C sends m to S: the nucleus takes buffer b7 from the pool and links it behind d; C continues at once, holding b7's identity.
  3. While C does other work, D sends x to C: another buffer lands in C's queue.
  4. C calls wait answer(b7) before the answer exists: C waits.
  5. S calls wait message, first come, first served: d first, and a copy of d goes into S's memory (S's answer to D is not drawn).
  6. Then b7: a copy of m goes into S's memory, and b7 stays in the nucleus, held for the answer. Arrival order has settled the contest between D and C.
  7. S sends its answer: the nucleus puts it in the same buffer, now b7 · r, which joins C's queue behind x, an unrelated message.
  8. C's wait answer(b7) takes b7 past x, by its identity, which the nucleus checks: a copy of the answer goes into C's memory. Nobody competed for the reply.
  9. The conversation is over: b7 goes back to the pool.

The pool of buffers is finite, with "a limit is set to the number of messages a process can send simultaneously"3. A send to a process that does not exist gets "a dummy answer generated by the system nucleus"3. The nucleus can give such an answer because it sees every process, and section 11 returns to it. Kahn's paper of 1974 names this nucleus among the systems showing that its own primitives, wait and send, "are not too far from reality"8,3. The claim is about the primitives, not the network, since wait message merges every sender into one queue, the mailbox family's resolution. The full account of the nucleus, with the two further primitives and where its design places the risk of a conversation, is in appendix A.

The machine thus splits each conversation in two and resolves the halves differently: requests, from many senders, by their order of arrival; replies, each identified, by no contest at all.


7. Channels: synchronous communication and guarded choice (CSP, occam, Go)

In the RC 4000, only the replies travelled uncontested, by identification. The channel family builds a whole language from meetings of named parties: Hoare's CSP of 1978, its channel form of 1985, occam and Go.

A guarded choice in the program is the place where the programmer marks a contest for the language to resolve. A merge on a channel is left to the scheduler.

Hoare, 1978: communication as a primitive

Hoare's paper proposes input and output as basic primitives of programming, and parallel composition of communicating sequential processes as a fundamental way to structure programs10. Four of its choices define the language as this story reads it10:

  • No shared variables. Processes in a parallel command are disjoint10.
  • Named partners. An input names its source process and an output its destination. X?(x, y) in one process and DIV!(3*a+b, 13) in the other together act as the assignment (x, y) := (3*a+b, 13)10.
  • No buffering. "There is no automatic buffering"10. Whichever side is ready first waits, and "Such delay is invisible to the delayed process"10. The two commands execute simultaneously.
  • Partner termination. An input fails if its source has terminated, and an output fails if its destination has10.

The list also fixes what the language lacks: there is no connection and no channel object. Each exchange is a single event between two named processes, and nothing persists after it. To send again, the programmer writes another output command, which must meet another input. The only lasting structure is in the program text. The parallel command fixes the set of processes10. Each command names the process it addresses, and that name may carry a subscript computed at run time10.

The picture for the handshake is a phone call: both parties must be on the line at the same moment, and nothing is said until both are. A buffered send is a letter: it is posted and the sender walks away.

Guarded choice

One construct makes this language more than a set of single meetings between named parties. A guard may end in an input command, and the guarded branch runs only if the named source is ready to output. When several are ready, exactly one is chosen, arbitrarily10.

*[ n < 10; producer?x → buffer(n) := x; n := n + 1
 □ n > 0;  consumer?more() → consumer!buffer(0); shift
 ]

This sketch of Hoare's bounded buffer shows the idea. The process offers two communications and takes whichever partner turns up. In the kitchen, it is a cook between the delivery door and the pass, who answers whichever bell rings: the door's while the shelf has room, the pass's while it holds stock. This is the guarded choice in the program: the programmer marks one visible point, the language selects among the partners ready there, and everything else stays deterministic.

Kahn's networks and CSP compared

Do Kahn's networks and CSP differ by their synchrony or by choice? They share three things: no shared memory, partners fixed by the program text, and a read that waits until a value arrives. The fixed partner is a channel's writer in Kahn's networks and the named process in CSP 1978, where no channel object exists. Hoare listed the differences himself10. Kahn's processes are "strictly deterministic: No choice is given between alternative sources of input". Their output is "automatically buffered to any required degree". It "can be automatically fanned out to any number of processes". They run forever, where CSP's parallel command "is normally intended to terminate". The 1985 book repeats the first three, determinism, buffering and fan-out26. Of these, only the first decides the values computed. By the rule of section 8, buffering decides waiting, deadlock and what the sender knows in a network without choice. A value copied to several readers is the same value for each. Termination ends a history without changing its values, unless a process acts on a partner's termination, which the conditions below exclude.

A CSP program therefore computes as a Kahn network whose channels hold nothing when it meets four conditions. Its processes are deterministic, and no alternative command has two guards that can succeed together, whether by an input or by boolean guards alone10. Every channel has one writer and one reader, and no process acts on a partner's termination, which in CSP 1978 makes an input fail10. It then produces no value the Kahn network would not produce, and it waits more. It can deadlock where the unbounded network runs on, as the cycle at the end of this section shows (run). With guarded choice the program leaves Kahn's conditions. What separates the two models in their results is choice, not synchrony. Hoare credited the buffered design with "an elegant theory which permits proof of the properties of programs"10.

Reasons for synchronous communication

From today's side, the unbuffered send can look odd. Four reasons are given for it, from different sources:

  1. Provability. A communication is one event shared by two processes. With a buffer there is a send event, a receive event, and hidden queue state between them. The algebra of CSP that followed (Hoare's 1985 book) is built on the shared event26; this is a later reading, not a reason given in 1978.
  2. No arbitrary buffer size. Hoare chose size zero and let programmers write buffers as processes, for two reasons: buffering is less realistic on separate processors, and it can be built from the primitives where needed. He also concedes the symmetric point, that synchronization could be built from buffered commands10.
  3. Knowledge. After a synchronous send, the sender knows the receiver has the value. It can make assertions about the receiver's state11.
  4. Backpressure. A fast producer cannot run ahead and fill memory. Any bounded buffer that blocks its sender when full, zero included, has this property. The property is therefore a reason for bounding rather than for size zero, and the 1978 paper does not give it.

From named partners to channels

In the CSP line, the handshake survived; the naming did not. CSP 1978 had a weakness, and Hoare discussed it himself10. Consider a buffer process B between a producer P and a consumer C. In 1978 style, B's code names its partners:

B :: *[ x: integer; P?x → C!x ]

To reuse B between two other processes, X and Y, the programmer must rewrite B. Hoare called port names "attractive" and judged them "semantically equivalent" for point-to-point connections10. With channels, B names its own two ends, and whoever assembles the system plugs real channels into them:

B(in, out) = in?x → out!x → B(in, out)

In this line the parameters in and out are the channels; the right-hand side is B's behavior, not a channel. Read in order:

  • in?x: receive a value on the first channel and name it x;
  • out!x: send x on the second channel;
  • each arrow: "then".

A CSP channel is a name fixed in the program text and joined when the system is assembled: B(left, mid) ‖ B(mid, right) connects two buffers through the channel mid. A process's channels belong to its alphabet, which Hoare's book makes "a permanent predefined property of an object"26. In the book, a process's set of channels never changes at run time. A Go channel, by contrast, is a value (the reply channel below), and so is a name of the π-calculus (section 12). The book writes the buffer and the chain of two buffers as

COPY = µ X • (left?x → right!x → X)
COPY >> COPY

where P >> Q connects the right channel of P to the left channel of Q and conceals the messages on it26.

The handshake is unchanged. The only change is that a process names its own ends instead of its partners. Hoare's 1985 book writes communication over named channels26 and names occam among the languages built on them26. When people say "CSP" today, they usually mean this channel version, and that is what Go took up. The dates put the two ideas in an unexpected order. Buffered constructs came first: the RC 4000's finite pool in 19693 and Unix pipes in practice (1972, by Ritchie's account)18, Kahn's networks in theory (1974)8. Hoare described named ports joined by synchronous channels as an alternative in 197810, and CCS (1980) and occam (1983) made named synchronous channels the norm. Hoare's 1985 book uses channels as its notation for communication26.

Go: the rules as the specification states them

Go's specification states the rules of this family14:

  • With capacity zero, a channel is unbuffered and "communication succeeds only when both a sender and receiver are ready". With capacity n, a send proceeds if the buffer is not full and a receive if it is not empty.
  • A channel is a first-in-first-out queue: with one sender and one receiver, values are received in the order sent; the specification states no order among concurrent senders.
  • A send on a closed channel panics; a send or receive on a nil channel blocks forever.
  • A select chooses among cases that can proceed by "a uniform pseudo-random selection". With none ready, it takes default if there is one; otherwise it blocks.

Go's select allows send cases as well as receive cases. Hoare's 1978 language allowed only input guards10. That difference matters in section 12, where a choice that waits on a send and a receive at once is the problem.

Go's reply channel is the RC 4000's identified conversation with a channel as the identity. A request carries the channel on which its answer is to come back, and only the client reads it, by convention. The type chan<- int stops the server from reading it, and nothing stops another goroutine that holds it.

reply_server.go, the lines shown
type req struct {
    n     int
    reply chan<- int // the server may only send on it
}

func counter(reqs <-chan req) {
    total := 0
    for r := range reqs { // one request at a time
        total += r.n
        r.reply <- total // the answer goes back where the request said
    }
}

// a client
reply := make(chan int)
reqs <- req{5, reply}
fmt.Println(<-reply)

A choice among several ready channels is easy to implement when one lock covers every channel, since the chooser inspects them all atomically and commits to one. Without a global lock, Go's runtime locks all of the select's channels in a fixed order, by address, before inspecting them, and commits to one case by an atomic operation13. A commit protocol between the two parties is another design, so that no partner is taken twice. The specification fixes what a select does, not how it locks14, and the one-lock version is the lab's teaching implementation. In the lab, the quest builds select on that one lock.

A timeout is one more branch of the choice, with the clock as an extra sender:

select {
case r := <-reply:
    use(r)
case <-time.After(100 * time.Millisecond):
    giveUp()
}
server ready firstboth ready: reply case takenselectserverclockuse(r)giveUp()rrclock fired firstboth ready: timeout case takenselectserverclockuse(r)giveUp()
select {case r := <-reply:    use(r)case <-time.After(100 * time.Millisecond):    giveUp()}

A select with a timeout as a small Petri net: a circle is a state, a bar is a communication, a dot is a token. A bar fires when its partner is ready and the goroutine's token is waiting; firing moves the token on and uses the partner's, so exactly one branch runs. Two runs stand side by side.

  1. The goroutine is blocked in select: neither the server nor the clock is ready.
  2. In one run the server is ready first: its bar fires, r crosses it, and the goroutine goes on into use(r).
  3. In another run the clock fires first: the timeout branch runs, giveUp().
  4. When both are ready as the select runs, it takes one case by a uniform pseudo-random selection, as the specification states: the two runs take different branches. In the run that takes the timeout, the server's send on the unbuffered reply channel stays blocked, since nothing receives it.

The server above sends every answer and serves one request at a time. With a timeout, its reply channel needs a slot. A client that gives up no longer receives, and the server's send on an unbuffered reply channel would then wait forever, holding up every later request. Creating each request's reply channel with make(chan int, 1) lets the late answer land in the slot14, where nothing reads it. The channel must be fresh for each request: a reused reply channel hands the late answer to the next request (run: "answer 5, expected 12", extra/s1/reply_combo.go). The server has applied the abandoned request all the same.

Deadlock by waiting

A handshake with no partner never completes, so a synchronous world fails by waiting. In extra/send_completion.go, part 3, main receives on a, a second goroutine waits to receive on b before it would send on a, and nobody sends on b:

a, b := make(chan int), make(chan int)
go func() { a <- <-b }()
fmt.Println(<-a)

Every goroutine is then asleep, and the Go runtime ends the program with the report recorded below. In the lab, part 2 builds the handshake and reproduces and repairs this state.

$ go run send_completion.go
fatal error: all goroutines are asleep - deadlock!

Does a deadlock need a lock, or only waiting? The lock was never the cause by itself: waiting is, and a lock is one thing a thread can wait for. Coffman, Elphick and Shoshani described a deadlock as the state in which "a group of two or more tasks is unable to proceed—each task monopolizing resources and waiting for the release of resources currently held by others in that group"27. With a message in place of the released resource, the description covers the cycle below. There each goroutine waits for a message the other will send only after its own send. The missing partner of the recorded run is the degenerate case, a wait on a message that no process holds. The runtime's criterion covers both: no goroutine can ever run again. Any operation that waits can play the part a lock played in session 7, and here a receive on a channel nobody serves plays it, as a send on a full or unbuffered channel can. Section 3 named the cost of sharing nothing, waiting replaces racing, and the failure of a world that waits is deadlock. The runtime's message is a last resort: it appears only when no goroutine can run again, and a goroutine in time.Sleep, or a pending timer, hides the deadlock of the others (run: extra/0b/deadlock_shapes.go)28.

The recorded run has one shape of deadlock, a missing partner: a goroutine waits on a channel that no goroutine will ever serve. The other shape is the cycle of section 2, two threads taking two locks in opposite orders. In its channel form, two goroutines each send to the other first and receive afterwards:

cycle_min.go, the lines shown
toMain, toOther := make(chan int), make(chan int)
go func() { toMain <- 101; fmt.Println(<-toOther) }()
toOther <- 1
fmt.Println(<-toMain)

Where two threads taking two locks in opposite orders can deadlock, depending on the interleaving, this cycle deadlocks in every run. On unbuffered channels each send waits for a receive that the other goroutine reaches only after its own send, and both wait forever. The runtime stops the program with "all goroutines are asleep - deadlock!", both goroutines blocked in a send (run: blocks/cycle_min.go).

Tu et al. found many such bugs in six Go systems: a missing send, a missing receive, or a channel never closed, each leaving a goroutine waiting forever29. Some come from a goroutine that holds a mutex while blocked on a send, which mixes the two worlds29.


8. Buffer capacity: waiting, deadlock and the sender's knowledge

Buffer capacity is the block's second parameter, set independently of the resolution of contests.

Hoare set the buffer to zero, Kahn to infinity, and the RC 4000 to a finite pool, and the actors of section 9 sit at the unbounded end. For buffering, an actor's mailbox can be read as the RC 4000's queue of one process with the limits taken off. There is no pool to exhaust and no limit on the messages a sender may have outstanding, so that a send returns at once30,31. The RC 4000, by contrast, limited the messages a sender could have outstanding, within one finite pool3. The comparison is a lens, not a lineage: as far as is known, the actor model arose independently of the machine (section 9). Its other differences, which do not concern capacity, come in section 9. Eventual delivery, the subject of point 4, is a fairness assumption and not a property of the buffer. In a network without choice or test for emptiness and with one writer and one reader per channel, buffer size does not decide the results, only waiting, deadlock and what the sender knows. In a program with choice or with a merge, several writers on one channel, buffer size can also change which outcomes are possible. Asynchrony, a send that does not wait for its receiver, is a matter of buffering; nondeterminism, once nothing is shared, is a matter of contests, tests for emptiness and processes nondeterminate inside (section 5). The two are set independently: an unbounded Kahn network is asynchronous and deterministic, and a CSP program with a guarded choice is synchronous and can be nondeterministic. Where a contest exists, capacity can still change which outcomes are possible, as the sentence above says.

In the kitchen, a synchronous channel is a plate handed from hand to hand, both cooks present at the same moment. A buffered channel is a pass-through shelf with a few slots, where a plate is put down and the cook walks off. The cook who puts down waits only when the shelf is full, and the cook who takes waits only when it is empty.

The cycle of section 7 shows what the number on a channel changes. At capacity 1, both sends land in a slot, both goroutines reach their receives, and the program ends. If each goroutine sends two values before it receives, the cycle returns at capacity 1, and capacity 2 breaks it again (run: blocks/cycle.go). The cycle's channels, one writer and one reader each and no choice or test on them, are point 1 below in a small case: a bounded buffer stalls where an unbounded one would not. The two goroutines' prints share one output, whose order can change at GOMAXPROCS 12; the values received never do (run: extra/s1/cycle_print.sh). The missing partner of section 7 stays at every capacity, since a receive on a channel nobody writes waits forever (run: extra/0b/deadlock_shapes.go, capacities 0, 1 and 10). Capacity decided who waits and whether the program deadlocks; it computed no other value. A buffer can break a cycle; it cannot supply a missing partner.

  1. Determinism comes from the absence of competition, not from the buffer. A Kahn network gives the same values with any buffer size. With buffers that are too small it can deadlock where unbounded buffers would not. Bounding can only cut the output short; it never changes a value produced. The pipelines of section 4 that have one writer per pipe are an instance: their pipes are bounded, and for the same input in the same environment their answers stay the same.

  2. Size zero changes what a choice means. With a handshake, a select picks among partners that are ready at that instant, and the sender knows the value arrived. With buffers, sends finish early, more interleavings of sends and receives become possible, and the sender knows less. The hello world of section 4, traced with make(chan string) and with make(chan string, 1):

    Step Capacity 0: who waits Capacity 1: who waits
    sender 1 sends sender 1, until main receives nobody: the value enters the slot
    sender 2 sends sender 2, until main receives sender 2, until the slot is emptied
    main receives nobody: main takes one of the two blocked senders, which continues nobody: main takes the slot's value, and sender 2's value enters the slot
    main receives nobody: main takes the other sender, which continues nobody: main takes the slot's value

    In both columns the scheduler decides which sender comes first, by the order in which it lets the senders reach the channel. The specification leaves the matching of blocked senders open14, and the gc runtime serves them in the order in which they blocked13 (run: extra/0b/sender_order.go). Here capacity changes who waits, not who can be served first. In a larger merge capacity can change that too. With two senders, A and B, and a receiver that starts receiving only after A signals that its send has completed, nothing is served at capacity 0, only A's value can come first at capacity 1, and either value can from capacity 2 on (run: extra/s1/merge_capacity.go).

  3. A bounded buffer moves the senders' contest. When it is full, senders compete for the next free slot instead of for the receiver. In Go, a send case in a select is ready on a buffered channel when there is room, and on an unbuffered one when a receiver is waiting14. On a closed channel it is always ready, and the send panics.

  4. Guaranteed eventual delivery with no bound on delay is where actors get unbounded nondeterminism. The source is the fairness assumption and not the buffer; Hoare's unbuffered example of section 10 would have the same property under a fair implementation. Senders never wait and delivery is assumed eventual, so outcomes can become infinite (section 10).

  5. Backpressure against load shedding. Unbounded buffers give no backpressure: a slow receiver goes unnoticed while its mailbox grows. Bounded buffers whose rule for a full buffer is to block the sender give backpressure, paid for in blocking bugs; a buffer that drops the message or returns an error instead sheds load without blocking.

The survey's three kinds of send sit on this scale11:

Kind Buffer Sender knows after send
Synchronous none the receiver has the value
Buffered finite the value is queued; the receiver may not have it yet
Asynchronous effectively unbounded nothing about the receiver; its message may describe state that is no longer current

The RC 4000 sits on the bounded side. The actors of section 9 sit at the far end, where a sender knows nothing about the receiver.

Buffer capacity and the semaphore count

Where a merge, a split or a choice admits more than one outcome, capacity does not choose among them; it decides which interleavings of sends and receives can occur. Capacity 0 excludes every interleaving in which a sender has finished a send its receiver has not taken. Capacity k excludes those in which a sender runs more than k values ahead of its receiver. An unbounded buffer excludes none beyond the rule that a value is received after it is sent. Among the interleavings left, the scheduler and the runtime choose. They choose, for instance, which of several blocked senders is served next. The specification leaves that choice open14, and the gc runtime decides it in the order the senders blocked13 (run: extra/0b/sender_order.go).

Session 7's locks play the same part for threads: more synchronization leaves fewer interleavings. The exact counterpart of capacity, though, is the initial count of a counting semaphore, not the lock. A lock forbids two threads to be in one region at the same time; a capacity forbids one side to run more than k steps ahead of the other. Dijkstra's bounded buffer enforces exactly that, with a semaphore of empty positions that starts at the buffer's size, taken by the producer before it writes and given back by the consumer after it reads4. A channel matches a semaphore only in that number. The semaphore's current count then changes as the buffer fills and empties, and a channel also carries the values. A buffered channel is therefore closer to Dijkstra's semaphores and an array.

Capacity of a channel (session 8) Semaphores (session 7)
0, the handshake a rendezvous: one semaphore signals that a value is there, a second that it was taken, a third keeps a second sender out (run: extra/0b/SemaphoreBuffer.java); Java's SynchronousQueue, which has no internal capacity, "not even a capacity of one"32
k Dijkstra's bounded buffer: "number of queuing portions" starts at 0, "number of empty positions" at the buffer's size, and a binary semaphore, "buffer manipulation", guards the array4; the producer ran at most k items ahead (run, k = 1 and 3)
unbounded Dijkstra's first buffer: "number of queuing portions" and the binary semaphore, no count of empty positions, so the producer never waits4

More synchronization always leaves fewer interleavings. It leaves fewer observable outcomes only where a contest exists, a merge, a split or a choice, or for threads a race the constraint covers. In a Kahn network every value produced is the same at every capacity, a small one only cutting the output short (point 1).

In both cases the number is fixed at creation, make(chan T, k) in Go and new Semaphore(k) in Java, and the code that uses it only sends and receives, or acquires and releases. Each still offers a way to read the current state:

  • len(ch) and cap(ch) give the number of queued elements and the size of a Go channel's buffer14;
  • availablePermits() gives a Java semaphore's count, a method "typically used for debugging and testing purposes"33.

A value read this way can be out of date by the next statement, since another thread can change it at once. A decision taken on it is a test for emptiness in the sense of section 5, and its outcome depends on timing. With twelve processors, goroutines that sent after checking that the buffer had room found it full in 2,370 of 100,000 trials, and in none with one processor (run: extra/0b/len_peephole.go). Java threads that acquired after seeing a permit would have blocked in 611, 598 and 668 of 20,000 trials (run: extra/0b/PermitsPeephole.java). Dijkstra's semaphore has no such operation: P and V "represent the only way in which the concurrent processes may access the semaphores"4.

Summary of block 1

From a distance, the buffer looks like a detail of how communication is built. It is more than that, and it leads back to session 7. The interleavings that message passing seemed to remove are still there. Where processes share nothing and messages carry values, they no longer appear as data races on shared memory. They appear as contests between messages at a point where several parties meet, as in the two-sender hello world of section 4, or as a test for emptiness. Whether the scheduler's choices can reach the results is decided by the model: under Kahn's conditions they cannot; with a merge, a split, a choice or a test for emptiness they can. Capacity, the initial count of a semaphore under another name, decides how much room the scheduler has: who waits, when, and how many interleavings remain. The interleavings go to two places. In the runtimes of this story, and in any runtime whose processes share one address space, the interleavings of accesses to shared memory go into the one trusted place underneath. That place is the buffer and the lock that orders them (section 3). The scheduler's choices that can reach the results go, in every model, to the few points where the program admits a contest: a merge, a split, a choice, or a test for emptiness (section 5). Message passing does not remove the interleavings; it moves them into one trusted place and onto a few marked points.

Block 1 has three parts. Sections 1 to 6 set up the problem and its vocabulary, alternating between machines and models; sections 4 and 5, Kahn's determinism and the three resolutions with the places where nondeterminism enters, are its core. Section 7 is the language that marks the contest in the program text: CSP. Hoare's 1978 paper proposed it as a programming language10, and his 1985 book made it an algebra26. Both occam and Go took it up, Go through Newsqueak and Limbo (appendix B). Section 8 opens the second parameter, capacity, where the models meet finite machines. An unbounded buffer does not exist, and a bounded one, when full, blocks the sender, drops the message or returns an error (point 5).

Is buffer capacity an implementation detail or a part of the model? It depends on what is observed. If only the values are observed, capacity is a detail in a Kahn network, since every value produced is the same at every size. If liveness is observed too, it is not, since a small buffer can deadlock where an unbounded one does not. With a choice or a merge, capacity can change which outcomes are possible, and it belongs in the model. The story shows both stances. Hoare put the size in the model, zero, for the reasons section 7 gives. The algebra of 1985 is built on the communication as one event shared by two processes (section 7, reason 1, a later reading and not a reason of 1978). Agha, in section 9, abstracts the bound away and defends unbounded buffers the way a semantics defends an infinite stack30. A parameter is an implementation detail only relative to what is observed. Block 2 takes the request half of the RC 4000's conversation to its full form, the mailbox: a send that never waits, an arrival order that the model leaves free, and a delivery that the model assumes.

Sources

The sources cited in this block, in the order of their first citation.

  1. datamuseum.dk, RC4000, RC8000 and RC9000, DDHFwiki, anonymous notes of 1996, page last edited 17 December 2023. The RC 4000's date, 1967.
  2. Politiken, Monday 8 September 1969, p. 4, "Ny EDB-filosofi fra Regnecentralen", signed "cauchi", scanned at datamuseum.dk, bits 30002322. The prototype at the ammonia plant at Puławy (spelled "Polawy" there), designed by Haldor Topsøe, and the fertilizer counted; Per Brinch Hansen, aged 30, leading the group (read on the scan, the age with less certainty than the rest); Peter Kraft named with "the first Danish multiprogramming system (… specially for the Polish machine)". Cited at Politiken, 8 September 1969.
  3. P. Brinch Hansen, The Nucleus of a Multiprogramming System, Communications of the ACM 13(4), April 1970, 238–241, 250; retyped reprint, https://people.cs.uchicago.edu/~shanlu/teaching/33100_fa15/papers/nucleus.pdf. The nucleus's three jobs, the names of processes, a process's incomplete knowledge of the others, and the details left to the system manual (p. 238); the four primitives and the two further ones, the one queue per process, the identification of a conversation, dummy answers for a missing or removed receiver, pool exhaustion, the operator's interrupt key, and semaphores rejected for "black sheep" (pp. 239 to 240); the limit on outstanding messages, the parent's storage and the risk of a conversation (p. 240); device handling and process control inside the nucleus, the uninterruptable mode, creation and removal in an interruptible process, the sizes of 4,800 and 6,200 words and the times of a send, a wait and a conversation (p. 241), the single processor implied and not stated, and the sizes read with less certainty than the times; the acknowledgement of Dijkstra (p. 250).
  4. E. W. Dijkstra, Cooperating Sequential Processes, EWD 123, Technological University Eindhoven, September 1965 (the date Brinch Hansen 1970 gives; the archive's catalog gives 1968); printed in F. Genuys (ed.), Programming Languages: NATO Advanced Study Institute, Academic Press, 1968, 43–112. The manuscript and its dates; it defines semaphores (§3.2), P and V "the only way in which the concurrent processes may access the semaphores", which appear earlier, in EWD 74; the unbounded buffer (§4.1) and the bounded buffer with its "number of empty positions" (§4.3).
  5. ISO C++ working draft, [intro.races] (6.10.2.2), paragraph 17, in the eel.is rendering consulted on 27 October 2026, https://eel.is/c++draft/intro.races. A data race results in undefined behavior.
  6. The Go Memory Model, version of June 6, 2022. A racy program without meaning in C and C++ (informal overview); a racy read of a word-sized location sees some write; a race on a multiword value may tear it and corrupt memory; an implementation may report a race and stop the program.
  7. The Java Language Specification, Java SE 21 edition, chapter 17, "Threads and Locks", §17.4 (memory model, happens-before) and §17.7 (non-atomic treatment of double and long). What a racy read may return in Java. Cited at JLS 17.7; JLS 17.4.
  8. G. Kahn, The Semantics of a Simple Language for Parallel Programming, in J. L. Rosenfeld (ed.), Information Processing 74, Proceedings of IFIP Congress 74, North-Holland, 1974, 471–475 (editor and pages as dblp gives them, not seen in the copy); read in a retyped copy without page numbers. Processes on FIFO channels with one writer each and blocking reads (§2, restriction iii: a process "cannot be waiting on data coming from one or another of its input lines"); a process a function of the histories of its inputs, and a network determinate (§2.2); the fixed-point argument; a schedule fair enough, and less output under an unfair one (§3); the nucleus of the RC 4000 cited as reference [3] among the systems whose primitives are "not too far from reality" (§6), where the word determinate stands. Cited at §§2.2 and 6.
  9. E. A. Lee and T. M. Parks, Dataflow Process Networks, Proceedings of the IEEE 83(5), May 1995, 773–801; read in the preprint of 27 March 1995, whose section numbers are used. Kahn process networks (§2.1) and networks of monotonic processes determinate (§2.2); the five ways to add nondeterminism (§2.2); sequential processes with blocking reads continuous (§2.4.6). Cited at §2.1 and §2.4.6.
  10. C. A. R. Hoare, Communicating Sequential Processes, Communications of the ACM 21(8), August 1978, 666–677, doi 10.1145/359576.359585. Input and output as primitives and the common store (p. 666); named partners, no buffering, guarded choice (p. 667); disjoint processes (p. 668); termination and input guards only (p. 669); explicit naming, port names and buffering as alternatives (§7, p. 675); the bounded buffer, the dining philosophers and the prime sieve among its examples; the alternative command, with boolean guards that may be true together and an input from a terminated process that fails (pp. 669–670); the comparison with Kahn's design, its four differences, and the credit of "an elegant theory which permits proof" (§7.7, p. 676); fairness (p. 676); the reference list, which cites Dijkstra, Kahn as [12] and Brinch Hansen only for Concurrent Pascal as [2]. Cited at pp. 666, 668; pp. 667, 669; §7.3, p. 675.
  11. G. R. Andrews and F. B. Schneider, Concepts and Notations for Concurrent Programming, ACM Computing Surveys 15(1), March 1983, 3–43. Message passing defined, and direct naming (p. 25); the port, one receiver and many senders (pp. 26 to 27); the three kinds of send and the assertions a sender can make after each (p. 27); send and receive in guards an open problem (p. 29). Cited at pp. 25 to 27.
  12. P. Brinch Hansen (ed.), RC 4000 Computer Reference Manual, 2nd edition, Regnecentralen, Copenhagen, June 1969, RCSL 55-D1, §7.1, p. 33. Interrupts disabled on entry to the interrupt program (§7.1); instruction-exception interrupts never disabled (§7.2).
  13. The Go runtime, src/runtime/chan.go and src/runtime/select.go, read at tag go1.27.3, https://github.com/golang/go/blob/go1.27.3/src/runtime/chan.go and https://github.com/golang/go/blob/go1.27.3/src/runtime/select.go. The channel as hchan, with a buffer, queues of waiting goroutines and a lock (chan.go, lines 34–55); waiting senders and receivers served first in, first out (chan.go, 858–904); a select that locks its channels in address order (select.go, 206–252).
  14. The Go Programming Language Specification, language version go1.27 (May 26, 2026), sections "Channel types", "Send statements", "Receive operator", "Select statements", "Close" and "Length and capacity". Unbuffered and buffered channels, FIFO order and no order among concurrent senders, a send on a closed channel and a nil channel, when a send case is ready, the uniform pseudo-random choice of select, and nothing said of locks.
  15. G. Kahn and D. B. MacQueen, Coroutines and Networks of Parallel Processes, Information Processing 77, Proceedings of IFIP Congress 77, North-Holland, 1977 (the printing not opened); read in IRIA Rapport de Recherche 202, November 1976 (OCR scan; pages cited as the PDF's). The availability of an item at an input port "cannot be tested", "a deliberate decision to exclude time-dependent input/output behaviour" (§2.3); a channel bound to a single producer, several consumers sharing an input line, each reading every value (§2.4); Conway's coroutines and the Unix "pipelining combinator" cited.
  16. IEEE Std 1003.1-2024, pipe(), https://pubs.opengroup.org/onlinepubs/9799919799/functions/pipe.html, and write(), https://pubs.opengroup.org/onlinepubs/9799919799/functions/write.html. A write to a full pipe blocks; a write to a pipe that no process reads fails with EPIPE and raises SIGPIPE.
  17. K. Thompson and D. M. Ritchie, UNIX Programmer's Manual, Third Edition, Bell Telephone Laboratories, February 1973, page pipe(II) dated 15 January 1973, in the archive v3man.tar.gz. Pipes documented in 1973.
  18. D. M. Ritchie, The Evolution of the Unix Time-sharing System, AT&T Bell Laboratories Technical Journal 63(8), part 2, October 1984, 1577–1593, doi 10.1002/j.1538-7305.1984.tb00054.x; first given in 1979. Pipes appeared in Unix in 1972; the communication files of the Dartmouth Time-Sharing System (section "Pipes").
  19. M. D. McIlroy, untitled memo, signed 11 October 1964, scan at https://plan9.io/cm/cs/who/dmr/mdmpipe.pdf (page "10", read as an image). "We should have some ways of coupling programs like garden hose".
  20. M. E. Conway, Design of a Separable Transition-Diagram Compiler, Communications of the ACM 6(7), July 1963, 396–408. A module coded as "an autonomous program which communicates with adjacent modules as if they were input or output subroutines" (p. 396); the coroutine structure of the COBOL compiler designed at Case.
  21. select(2), FreeBSD System Calls Manual, FreeBSD 15.1, page dated 25 June 2020. HISTORY: "The select() system call appeared in 4.2BSD"; DESCRIPTION: the descriptor sets replaced by "subsets consisting of those descriptors that are ready".
  22. M. K. McKusick, Twenty Years of Berkeley Unix, in Open Sources, O'Reilly, 1999 (read through a summarizing fetch, with less certainty than a page opened). 4.1c distributed in April 1983; "In August 1983, the system was released as 4.2BSD".
  23. select(2), 4.1cBSD manual page, headed 12 February 1983, in the 4.1cBSD tree of The Unix Heritage Society. The system call in the test release distributed in April 1983.
  24. S. J. Leffler, Bug fixes and changes in 4.2BSD, 1983, 4.2BSD usr/doc/uchanges. "The multiplexed file facilities are no longer part of the system. They have been replaced by the socket, and related, system calls".
  25. select(2), 4.2BSD manual page, dated 2 July 1983. "Select returns, in place, a mask of those descriptors which are ready".
  26. C. A. R. Hoare, Communicating Sequential Processes, Prentice Hall International, 1985; read in the electronic edition of 2022. Events shared by processes and channels as the standard notation (pp. 45, 113–114); an alphabet "a permanent predefined property of an object" (§1.1, p. 1); COPY (§4.2, p. 115) and the chaining operator >> (§4.4, pp. 131–132); buffering in a cyclic network and deadlock (§7.3.2, p. 219); three of the four differences from Kahn's networks, without the one on termination (§7.3.3, p. 221); occam named (§7.3.6, pp. 223–224). Cited at §4.2, p. 115; §4.4, pp. 131–132; pp. 113–114.
  27. E. G. Coffman, M. J. Elphick and A. Shoshani, System Deadlocks, ACM Computing Surveys 3(2), June 1971, read in a scan of the journal pages. The description of a deadlock and "deadly embraces" (p. 67); the four conditions (p. 70).
  28. The Go runtime, src/runtime/proc.go, function checkdead, read at go1.27.1 and compared with go1.27.3, https://github.com/golang/go/blob/go1.27.3/src/runtime/proc.go. The report "all goroutines are asleep - deadlock!" (line 6519) and no report while timers are pending (lines 6512–6516).
  29. T. Tu, X. Liu, L. Song and Y. Zhang, Understanding Real-World Concurrency Bugs in Go, ASPLOS 2019, 865–878, doi 10.1145/3297858.3304069; read in the authors' copy, whose fourteen pages are numbered here by position (proceedings page 864 + n). The uses of each primitive (§3.2); 171 bugs in six systems; blocking bugs and their causes (pp. 6 to 7); non-blocking bugs (pp. 10 to 11); message passing "does not necessarily make" programs less error-prone (§7, "Discussion and Future Work"). Cited at p. 7.
  30. G. Agha, Actors: A Model of Concurrent Computation in Distributed Systems, MIT AI-TR-844, June 1985, also his PhD dissertation at the University of Michigan; pages are the report's printed ones. The argument for asynchronous communication (pp. 19 to 22); the commands of his language SAL, among them become (p. 49) and send-to (p. 64), with the creation of actors (chapter 3); the atomicity of a communication kept by buffering (p. 20); arrival order arbitrary (p. 22, §2.4); delivery guaranteed after an arbitrarily long delay, and no guarantee that a message is "meaningfully" processed (pp. 23 to 24).
  31. J. De Koster, T. Van Cutsem and W. De Meuter, 43 Years of Actors: A Taxonomy of Actor Models and Their Key Properties, AGERE 2016, 31–40, doi 10.1145/3001886.3001890; read in the authors' copy. Agha's three primitives, credited there to his book of 1986 and his article of 1990 (p. 33); the Isolated Turn Principle (pp. 33 to 34); races across messages (p. 34); classic actors and the processes family (pp. 33, 35).
  32. Oracle, Class SynchronousQueue, Java SE 26 API documentation. Each insert waits for a remove; no internal capacity, "not even a capacity of one"; size() "Always returns zero".
  33. Oracle, Class Semaphore, Java SE 26 API documentation. A semaphore "maintains a set of permits"; availablePermits() "is typically used for debugging and testing purposes".

Session 8 · lecture notes, block 2

Block 2: Actors, mailboxes and the delivery assumption

Lecture notes of block 2, session 8, Message passing, 4 November 2026. Every program on this page was run while the session was prepared and its output recorded; what is shown is one sample of a run.

9. Actors and mailboxes: asynchronous sends into a mailbox in arrival order (Hewitt, Agha, Erlang)

The second family of message passing is the one in which a send never waits and every message goes to the mailbox of one named receiver.

The third resolution of section 5, arrival order in a queue, is the one the RC 4000 gave for requests. Senders put messages into one mailbox, and the receiver takes them in their order of arrival. After the RC 4000, two later designs reached the same answer, in two fields and for two different reasons.

Hewitt's actors, 1973

The actor model began in artificial intelligence, not in operating systems. Hewitt, Bishop and Steiger's 1973 paper, "A Universal Modular ACTOR Formalism for Artificial Intelligence"1, came out of Hewitt's earlier work on Planner. The model treats computation as a society of agents: "The model becomes a cooperating society of "little men" each of whom can address others with whom it is acquainted"1. The same paper states: "Every actor should act for himself or delegate the responsibility"1. As far as is known, the model arose independently of the RC 4000.

Agha's three primitives

The form in which actors are taught today dates from 1985, when Agha's thesis gave them their now-standard form2,3:

  • create makes an actor from a behaviour and returns its address;
  • send sends asynchronously to an address and returns at once;
  • become replaces the behaviour, so the next message is handled by the new one.

A toy version fits in a few lines of OCaml:

toy_actor.ml, the lines shown
type msg = Int of int | Ask of actor
and actor = { mutable behaviour : msg -> unit }

let mailroom : (actor * msg) Queue.t = Queue.create ()
let create b = { behaviour = b }
let send a m = Queue.push (a, m) mailroom        (* never waits *)
let become a b = a.behaviour <- b                (* next message, new behaviour *)

let run () =
  while not (Queue.is_empty mailroom) do
    let (a, m) = Queue.pop mailroom in
    a.behaviour m                                (* one turn, run to completion *)
  done

let rec counter n self = function
  | Int k -> become self (counter (n + k) self)
  | Ask reply -> send reply (Int n)              (* reply: send to the address given *)

The toy exhibits three properties of the model. A send only enqueues. Each delivery runs to completion, which is De Koster et al.'s Isolated Turn Principle: within one turn there is no low-level data race and no deadlock3. And the counter has no mutable variable of its own: its state lives in the behaviour it becomes next. The model's arrival order is arbitrary, which means that any order is allowed. The toy's mailroom holds the messages in flight, not an actor's mailbox. Picking a random pending message from it instead of the front therefore models an arbitrary delivery order. Random picking is one way to show that the order is not fixed, and exploring the orders means enumerating them. The toy compiles and runs as written (toy_actor.ml, run on record, OCaml 5.4: two increments and an Ask print 5).

Actors compared with worker pools and objects

An actor has its own identity, its own address and private state. Two familiar pictures misrepresent this, and both are wrong. The first is interchangeable labour pulling work from a common pile; an actor is closer to a person with a mailbox of their own. In the kitchen, each cook has an order spike of their own, the ticket is pinned on that cook's spike, and only that cook reads it, in the order the tickets were pinned. The second picture is the object: an actor resembles an object that other actors can write to but never call, so nothing returns. A sender that wants an answer puts its own address in the message.

A third picture is closer and still different. An RC 4000 process is a thread in a loop beside its mailbox: wait, handle, wait again. A classic actor inverts that structure. It has no loop and never waits; it is a handler that the runtime calls once per message, and become records the behaviour for the next message. Classic actors are therefore event handlers, a state machine written by hand, which is why programming with them resembles asynchronous programming. Erlang restores the loop: a process loops, blocks in receive, and passes its state through recursion. That is the split between Classic Actors and the Processes family3.

The guarantees of actor theory, and their limits

A model in which a send returns at once has to state what happens to the message afterwards.

Guaranteed Source
Every message sent is eventually delivered, after an arbitrary but finite delay2 Agha 1985, p. 23
A message arrives whole, an aim the model states rather than a guarantee it proves2 Agha, p. 20
One turn is isolated: no low-level race or deadlock inside it3 De Koster et al., pp. 33–34
A message is received only after it is sent4 causality; Armstrong p. 26 states the same principle
An actor sends to the actors it is acquainted with1 Hewitt 1973, p. 236, as a metaphor

Actor theory does not guarantee arrival order2 (it is arbitrary), a bound on delay, or a reply. Nor does it guarantee that a delivered message is "meaningfully processed"2, or freedom from races and deadlocks across several messages3. "Delivery guaranteed" is an idealization of the model, not a TCP-like protocol. Agha defends it the way a semantics defends an infinite stack: unbounded buffers do not exist physically, but the model abstracts from such limits2. TCP keeps order per connection and obtains reliability by retransmission; the actor model guarantees no order and assumes delivery.

Agha's argument for asynchronous communication

Where section 7 gave the reasons for the handshake, Agha argues the opposite2:

  • "Intuitively, there can be no action at a distance." A sender can only know a receiver is ready by first sending it something, so synchronous communication is always built on asynchronous communication.
  • Without buffering, an actor cannot send a message to itself, and recursive computation requires that.
  • A fast sender, a typist faster than an editor, should not be held to one character at a time.

Armstrong's argument from fault isolation

The second of the two came from Ericsson, and its argument reaches asynchrony from a different premise. Erlang's development at Ericsson began in 1986, with first experiments in 1987. Erlang arrived by an independent route at semantics like the actor model's, a design convergence and not a derivation from actor theory. Its motive was fault tolerance, not artificial intelligence. Armstrong's 2003 thesis sets out the argument4:

  1. The essential problem in a fault-tolerant system is fault isolation: errors in a faulty module must not reach a correct one4.
  2. Any shared resource lets an error in one process corrupt it, so processes share nothing4.
  3. Message passing must be asynchronous: "If process communication is synchronous then a software error in the receiver of a message could indefinitely block the sender of the message destroying the property of isolation"4.
  4. Delivery is not guaranteed (across nodes, or to a dead process; section 10). The sender can learn that a message arrived only from a confirmation sent back4.

Armstrong calls the result "send and pray"4. The argument has two gaps. Step 3 assumes a synchronous send with no timeout, which a timed send would bound. And an unbounded mailbox leaves one shared resource, the node's memory, which a stuck receiver's mailbox can exhaust for every process. Armstrong concedes a version of this gap himself, for operating-system processes that share one CPU and one memory: he calls isolation "only true to a first approximation"4. Erlang then adds back one guarantee as "a design decision": messages between a given pair of processes arrive in the order sent4. The reference manual states that guarantee for signals5. In the message queue it holds for ordinary messages and the default mailbox5; the subsection "Mailbox semantics in Erlang" below names the exception. Across different senders no order is guaranteed, and how their messages interleave depends on the scheduling.

Mailbox semantics in Erlang

The semantics are observable in a running system, for ordinary messages and the default mailbox. Since OTP 28.0, a receiver may enable priority messages, which it queues ahead of ordinary ones. Two messages from one sender can then stand in its queue in another order than they were sent5. The text leaves priority messages aside. The recorded run of mailbox.erl exhibits four behaviours:

  • A send returns before any process receives.
  • Each sender's own order is kept.
  • A selective receive takes a matching message from behind two earlier ones, so a mailbox is not a queue read from the front. In the lab, the quest's extra adds selective receive to the mailbox.
  • A send to the pid of a dead process returns normally and nothing reports the loss; a send to a registered name that no longer exists raises badarg (registered_send.erl, run on record, OTP 29).

The last point is where Erlang and the RC 4000 differ: the RC 4000 returns a dummy answer. With a monitor, a partner's death becomes an ordinary message, {'DOWN', Ref, process, Pid, Reason}5.

The lost update across two messages

Everything in this section so far has removed shared variables from the program. The lost update of section 2 nevertheless returns without any shared variable: not as a data race, since no two accesses conflict, but as a race between messages. A counter process owns its state, and two clients each read it, then write it back plus one (counter.erl, run on record: the increment was lost in 2,953 of 3,000 runs, Erlang/OTP 29):

counter.erl, the lines shown
counter(N) ->
    receive
        {get, From} -> From ! {value, N}, counter(N);
        {set, M}    -> counter(M)
    end.

%% each of two clients:
C ! {get, self()},
receive {value, V} -> C ! {set, V + 1} end.

Both clients can receive 0 before either sets, and both then set 1: one increment is lost. The counter's own code is sequential; the race lies in the order in which its mailbox merges the two clients' messages. The fix makes the invariant one message, {incr}. In the lab, the warm-up's counter server shows the same loss on the nucleus, and incr as one message repairs it. In the kitchen, the cutting board is gone, and two client cooks still collide at the counter's spike. Each client cook reads the count before either writes it back: the recipe spanned two tickets.

client 1counterclient 2N = 0{get, C1}{get, C1}{get, C2}{get, C2}{value, 0}{value, 0}V = 0{value, 0}{value, 0}V = 0{set, 1}{set, 1}{set, 1}{set, 1}N = 1N = 1two increments, N = 1{incr}{incr}{incr}{incr}N = 1N = 2
counter(N) ->  receive    {get, From} ->      From ! {value, N},      counter(N);    {set, M} -> counter(M)    {incr} -> counter(N + 1)  end. %% each of two clientsC ! {get, self()},receive {value, V} ->  C ! {set, V + 1}end.C ! {incr}.

Two clients each read the counter, then write back the value read plus one. The counter takes one message at a time; when both reads come before either write, two increments leave N at 1. The race is between messages, and no variable is shared; one message carrying the whole increment removes it. On record (counter.erl, Erlang/OTP 29): N ended at 1 in 2,953 of 3,000 runs.

  1. The counter process holds N = 0; two clients will each read it and write it back plus one.
  2. Both clients send get; the two requests wait in the counter's mailbox in arrival order, client 1's first in this run.
  3. The counter takes client 1's get and answers 0.
  4. It takes client 2's get and answers 0 too: neither client has written yet.
  5. Both clients send set 1, the value read plus one.
  6. The counter takes the first set: N = 1.
  7. It takes the second set: N = 1 again, after two increments.
  8. The repair makes the increment one message: each client sends incr.
  9. The counter's own sequential code applies both: N = 1, then 2.

The mailbox that merges requests also receives replies. The RC 4000's identification of a conversation returns here, with a reference in place of a buffer identity, checked by the program's pattern instead of by the nucleus:

Ref = make_ref(),
Server ! {request, self(), Ref, Data},
receive
    {reply, Ref, Result} -> Result
after 1000 -> timeout
end

The reply comes back into the same mailbox as every other message. The unique Ref and the selective receive let the client find its own reply. The RC 4000 did the same with the buffer's identity, checked by the nucleus. The Erlang client finds its reply by a reference in one mailbox; the Go client of section 7 waits on a channel that, by convention, only it reads.

RC 4000clientserverrequestclient's queuexb7the nucleus checks the identityGoclientserverrequestreply5replythe program keeps it, by conventionErlangclientserverrequestclient's mailbox{log}Refthe program keeps it, by convention
-- RC 4000buf := send message(S, m)answer := wait answer(buf)// Goreply := make(chan int)reqs <- req{5, reply}r.reply <- totalfmt.Println(<-reply)%% ErlangRef = make_ref(),Server ! {request, self(), Ref, Data},receive {reply, Ref, Result} -> Result

One request and its reply in three systems. In each, one object identifies the conversation and leaves with the request: in the RC 4000 and Erlang it comes back with the reply, in Go the reply comes back by it. The three differ in what that object is and in who checks it.

  1. One client and one server in each system, nothing sent yet; the client's queue and mailbox already hold a message from some other process, x and {log}.
  2. RC 4000: the request travels in buffer b7.
  3. The answer comes back in the same buffer, into the client's queue behind x; wait answer(b7) takes it by its identity.
  4. Go: the request carries a fresh channel, reply.
  5. The server sends the answer on that channel, and only the client reads it.
  6. Erlang: the request carries a fresh reference, Ref.
  7. The answer comes back into the client's mailbox beside other messages, tagged with Ref, and the receive's pattern picks it out.
  8. The client takes its reply past the other message, by its identity, and who checks that identity: in the RC 4000 the nucleus; in Go and Erlang the program, by convention.

Message order, and what a message carries

With both families defined, the order of messages can be stated for each system of the story:

Model Order
Go channel a first-in-first-out queue: with one sender and one receiver, values are received in the order sent; no order among concurrent senders6
CSP 1978 no queue; each exchange is one event between two sequential processes, so the exchanges of a pair are ordered; choice among senders arbitrary7
Actor theory arbitrary2
Erlang per pair of processes4, for ordinary messages and the default mailbox (the subsection "Mailbox semantics in Erlang" names the exception); selective receive can take a later message first5
RC 4000 one queue per process; two primitives allow any order8
sentarrivedreceivedfirstsecond{urgent, 3}"first""second""urgent"firstsecond{urgent, 3}{urgent, 3}receive {urgent, N}firstreceive firstsecondreceive second"first""second""urgent""first""second""urgent"a Go channel: in the order sentthe actor model: any arrival ordersentarrived
Self ! first,Self ! second,Self ! {urgent, 3},receive {urgent, N} -> N end,receive first -> ok end,receive second -> ok end.c := make(chan string, 3)c <- "first"; c <- "second"c <- "urgent"v1, v2, v3 := <-c, <-c, <-c%% actor model: delivery in%% an arbitrary order

The same three messages, from one sender to one receiver, in the order sent, the order they arrived and the order they were received. A crossing line is a message taken out of the order above it.

  1. One process sends itself first, second and {urgent, 3}.
  2. Erlang keeps the order between one sender and one receiver: they arrive in the order sent, so the lines run straight.
  3. The selective receive takes {urgent, 3} first, past the two earlier messages, as the recorded run of mailbox.erl shows: the orange line is the message taken out of order, the other two shift right, and the crossing is the pattern's doing, not the transport's.
  4. A Go channel with one sender: the order sent is the order received, and nothing crosses.
  5. The actor model leaves arrival order arbitrary: any of the six orders may arrive, three drawn here.

What a message carries also differs:

  • Erlang copies the data of a message, except reference-counted binaries and literals, which are shared on one node5;
  • a Go channel passes the value it is given, so a sent pointer stays shared (shared_pointer.go);
  • Rust moves ownership with the send for a value that is not Copy; a Copy value is copied, and an Arc moves a handle to data that stays shared9,10 (16.2 and 16.3; std::sync::Arc).

On one node, nothing in the systems of this section creates duplicates. Duplicates arrive with retries across a network; Birrell and Nelson's protocol suppressed them, and after an exception the call had run "either once or not at all--the user is not told which"11.


10. Fairness: eventual choice and eventual delivery

Both families now place messages, or offers to communicate, where they may wait on a choice, and one guarantee becomes pressing: whether a ready communication must eventually happen. The two traditions answer differently, and the difference is often misread as one about reliability.

CSP. CSP has no messages in transit, so nothing can be lost; its fairness question concerns choice. Hoare's example: X sends stop() while Y loops, either receiving the stop or incrementing a counter. An implementation that always prefers the counter passes X over forever. Hoare declines to have the language forbid that, because the implementation would then have to complete programs with unbounded nondeterminism; so "a proof of correctness must not rely on this property"7.

Actor theory. The guarantee of eventual delivery is a fairness assumption. It brings unbounded nondeterminism: a program can be certain to terminate yet have infinitely many possible results. Clinger's example is a counter that increments until a "stop" message arrives. The stop is guaranteed to arrive, so the counter always halts, but at any number at all. Dijkstra held that unbounded nondeterminism could not be implemented; Hewitt and Clinger argued that real arbiters behave exactly that way.

CSP 1978 Actor theory Erlang, to a live process on the same node Erlang, to a dead process or another node
A ready message is eventually taken or delivered not guaranteed7 guaranteed2 arrives after an unspecified but positive time, unless the receiver has terminated, and is dropped before the queue if sent through an inactive alias5; whether it is handled is the receiver's doing not guaranteed4
A message can be lost no such thing exists no, by assumption2 only one sent through an inactive alias, dropped before the queue5 yes4

In everyday programming the question is whether a program can count on the receiver to handle a sent message eventually. Go's select chooses among the ready cases by a uniform pseudo-random selection, each time it runs6. That a select eventually takes a case which stays ready, with probability 1, is an inference under a model. In that model the choices are independent, and the goroutine evaluates the select again and again while the case stays ready. The specification guarantees nothing of the kind, nor anything about blocked senders on one channel. Erlang's manual says a signal arrives after an unspecified but positive time, and names when it does not: a terminated receiver, a distribution channel that goes down5. A message sent through an inactive alias is dropped before it enters the queue5. Arrival says nothing about the process handling it, and the order between one pair of processes is kept even across nodes5.


11. The delivery assumption: the boundary with session 9

The last column of the table, a dead process or another node, is where this session stops. On one runtime, a death can be reported exactly: the RC 4000 nucleus returned a dummy answer8, and Erlang's monitors turn a death into a DOWN message5. In the lab, the quest's other extra removes a process and watches the dummy answers arrive.

This session assumes delivery on one node. The delivery assumption is a teaching assumption. The RC 4000's paper states it for a live receiver on one machine, and neither Erlang's manual nor Go's specification states it as such8,5,6. The assumption has two parts. First, every message sent to a live process reaches its queue, except one sent through an inactive alias (section 10). Whether the process handles it is its own doing. Second, a death is reported exactly wherever the program asks for the report, by the RC 4000's dummy answer or an Erlang monitor. A plain send to a dead process reports nothing (section 9). What session 9 changes is that assumption, not the number of machines. Session 9 starts from a crash on one machine, observed through a link and a monitor, and only then gives up delivery. The impossibility result of Fischer, Lynch and Paterson12, failure detectors and Waldo's partial failure13 belong to that session.


12. The cost of message passing, and the relation between channels and actors

Section 3 made a move, sharing nothing, and named its cost: waiting replaces racing.

The bug study of Tu, Liu, Song and Zhang

Tu, Liu, Song and Zhang studied 171 concurrency bugs in six Go systems14:

Shared memory Message passing
Blocking bugs (85) about 42% about 58%
Non-blocking bugs (86) about 80% about 20%

"Contrary to the common belief that message passing is less error-prone", more blocking bugs came from message passing14. The study's other half points the other way: far fewer non-blocking bugs came from message passing14. Read together, the two halves say: in the systems studied, message-passing bugs were mostly blocking and shared-memory bugs mostly non-blocking14. That is consistent with the story, in which the price of removing sharing is waiting. The study also counts the uses of each primitive14 and notes that shared-memory primitives are used more often. By its count, then, message passing is even likelier to cause a blocking bug. What the study does not establish is whether message passing creates or prevents bugs overall.

Message passing can also fail the opposite way, by letting sharing back in, and shared_pointer.go exhibits it. A pointer sent on a channel stays shared, and the race detector, in an instrumented run, reports a write after the send. "Share by communicating" is a convention, and a program can break it without the compiler detecting it. Safe Rust closes the data-race hole, not the sharing. Sending moves ownership. A program can mutate data that an Arc keeps shared after a send only through a type that synchronizes its own access:

  • a Mutex;
  • an RwLock;
  • an atomic;
  • a OnceLock.

The type system forbids unsynchronized conflicting accesses in safe code and does not forbid shared state. Unsound unsafe code reopens the hole. An unsound implementation of Send or Sync on a wrapper of a raw pointer is one example9,10.

The π-calculus and the mutual encodings of channels and actors

The two families were presented as two answers to one question, and a single calculus shows how close the answers are. Milner, Parrow and Walker's π-calculus (1992) makes channel names values that can themselves be sent on channels15. In it, an actor's address is a channel with exactly one reader, the survey's port16, and a channel can in turn be written as an actor that holds a queue. So, in the calculi studied, each family can be translated into the other (asynchronous channels without choice, in Fowler, Lindley and Wadler17), with what a translation preserves depending on it. Two limits are known for those calculi and their criteria:

  • Mixed choice. Palamidessi showed that a choice that waits on a send and a receive at once cannot be encoded uniformly in the asynchronous π-calculus while preserving a reasonable semantics18. A choice among inputs only can be19 (Nestmann and Pierce). That is the problem of send and receive statements in the same guards, which the 1983 survey called "an active research area"16. Palamidessi's uniformity criterion models a distributed implementation without a central coordinator18; reading the survey's problem as that requirement is this text's link. Go's select offers mixed choice6; pure actors cannot express it directly.
  • Fairness. The translations studied carry no fairness assumption across. Actor theory assumes eventual delivery and Go's channels guarantee none2,6, so fairness has to be assumed on each side separately.

Earlier accounts of the lecture's argument

The arc of this lecture is not new: the accounts that follow made its argument earlier, and the lecture credits them. Lee (2006, The Problem with Threads) argues that threads are "wildly nondeterministic" (p. 5), and that in Kahn process networks "the blocking reads ensure that every network defines a deterministic computation" (p. 11)20. Lee also argues that "Nondeterminism should be judiciously and carefully introduced where needed, and should be explicit in programs" (p. 15), for example by an explicit "NondeterministicMerge" (p. 11)20. Lee and Parks (1995, §2.2) list the ways nondeterminism enters21 (section 5). Van Roy and Haridi's CTM (chapters 4 to 5), as taught in UCLouvain's LINFO1131, starts from deterministic dataflow22. It adds ports "to overcome the limitations of declarative programming", because in client/server "the order of the requests cannot be determined in advance"22,23 (LINFO1131, lecture 5, 2021, slides 14 and 24). Fowler, Lindley and Wadler (2017) give typed translations between a calculus of asynchronous channels without choice and a calculus of actors. They add input-guarded choice to the channel calculus and leave its emulation by actors to future work17. What the story adds to them is the RC 4000 and the resolution of a contested communication as the axis of the comparison.

Actors and channels compared

In the lab, the closing comparison asks three questions of the three request-and-reply programs the students have written. The three questions are what has a name, who may receive, and which order is kept. A fourth question asks who checks the identity of a conversation.

The machine of 1969 belongs in the actor column for its requests, one queue per process served in arrival order. Its replies are identified conversations that no process contests, the idea that Go's reply channel and Erlang's reference both reuse. One system used two of the three resolutions by default (its two further primitives also let a program choose, appendix A). The lecture's two blocks are the identified reply taken to its full form as a channel and the request half taken to its full form.

The table compares the two families as Go and Erlang realize them.

Channel (Go) Actor (Erlang)
A send addresses a conduit, independent of processes a specific actor
Who reads any process holding it only the owner
Several sources the receiver chooses (select) one mailbox; patterns select messages
Resolution of a contested communication a guarded choice in the program; a merge left to the scheduler arrival order in the mailbox
Buffer often bounded (backpressure) conceptually unbounded
Failure not in the model (Go) usually built in (Erlang)
Across machines usually local addresses often work across nodes

Summary of block 2

Message passing does not abolish the scheduler. It confines the scheduler's choices that can reach the results to the meeting points. The confinement holds as long as processes share nothing by any other route, messages carry values, the runtime delivers them as section 11 assumes, and no process is nondeterminate inside itself. Kahn's networks show what happens if no meeting point is ever contested. CSP and Go let the programmer write the contest down. The RC 4000, actors and Erlang let the system settle it by merging. On one node, in every runtime of this story, and in any runtime whose processes share one address space, the shared memory is still there, hidden in one trusted place. The cost is paid in waiting, and in races between messages, which the protocol must rule out. Session 9 takes up the delivery assumption of section 11 itself: it starts from a crash on one machine and only then gives up delivery.

Sources

The sources cited in this block, in the order of their first citation.

  1. C. Hewitt, P. Bishop and R. Steiger, A Universal Modular ACTOR Formalism for Artificial Intelligence, IJCAI 1973, 235–245. The society of "little men" (p. 236) and "act for himself" (p. 238); Smalltalk, Simula-67 and Planner named among the model's influences, and not the RC 4000 (checked 28 October 2026, report B3).
  2. G. Agha, Actors: A Model of Concurrent Computation in Distributed Systems, MIT AI-TR-844, June 1985, also his PhD dissertation at the University of Michigan; pages are the report's printed ones. The argument for asynchronous communication (pp. 19 to 22); the commands of his language SAL, among them become (p. 49) and send-to (p. 64), with the creation of actors (chapter 3); the atomicity of a communication kept by buffering (p. 20); arrival order arbitrary (p. 22, §2.4); delivery guaranteed after an arbitrarily long delay, and no guarantee that a message is "meaningfully" processed (pp. 23 to 24).
  3. J. De Koster, T. Van Cutsem and W. De Meuter, 43 Years of Actors: A Taxonomy of Actor Models and Their Key Properties, AGERE 2016, 31–40, doi 10.1145/3001886.3001890; read in the authors' copy. Agha's three primitives, credited there to his book of 1986 and his article of 1990 (p. 33); the Isolated Turn Principle (pp. 33 to 34); races across messages (p. 34); classic actors and the processes family (pp. 33, 35).
  4. J. Armstrong, Making Reliable Distributed Systems in the Presence of Software Errors, PhD thesis, Royal Institute of Technology (KTH), Stockholm, December 2003; printed page numbers. Fault isolation, "only true to a first approximation" (p. 17); sharing nothing (pp. 19, 23); asynchronous sends (p. 23); delivery and confirmation (pp. 22 to 23); "send and pray" and order per pair of processes (p. 25); causality (p. 26). Cited at pp. 22–23.
  5. Erlang/OTP documentation, read at OTP 29.1.2: reference manual, "Processes", https://www.erlang.org/doc/system/ref_man_processes.html; efficiency guide, "Processes", https://www.erlang.org/doc/system/eff_guide_processes.html; module erlang, monitor/2, https://www.erlang.org/doc/apps/erts/erlang.html. Delivery of signals and their order, priority messages as of OTP 28.0, receive, the DOWN message, message data copied except refc binaries and literals on the same node.
  6. The Go Programming Language Specification, language version go1.27 (May 26, 2026), sections "Channel types", "Send statements", "Receive operator", "Select statements", "Close" and "Length and capacity". Unbuffered and buffered channels, FIFO order and no order among concurrent senders, a send on a closed channel and a nil channel, when a send case is ready, the uniform pseudo-random choice of select, and nothing said of locks.
  7. C. A. R. Hoare, Communicating Sequential Processes, Communications of the ACM 21(8), August 1978, 666–677, doi 10.1145/359576.359585. Input and output as primitives and the common store (p. 666); named partners, no buffering, guarded choice (p. 667); disjoint processes (p. 668); termination and input guards only (p. 669); explicit naming, port names and buffering as alternatives (§7, p. 675); the bounded buffer, the dining philosophers and the prime sieve among its examples; the alternative command, with boolean guards that may be true together and an input from a terminated process that fails (pp. 669–670); the comparison with Kahn's design, its four differences, and the credit of "an elegant theory which permits proof" (§7.7, p. 676); fairness (p. 676); the reference list, which cites Dijkstra, Kahn as [12] and Brinch Hansen only for Concurrent Pascal as [2].
  8. P. Brinch Hansen, The Nucleus of a Multiprogramming System, Communications of the ACM 13(4), April 1970, 238–241, 250; retyped reprint, https://people.cs.uchicago.edu/~shanlu/teaching/33100_fa15/papers/nucleus.pdf. The nucleus's three jobs, the names of processes, a process's incomplete knowledge of the others, and the details left to the system manual (p. 238); the four primitives and the two further ones, the one queue per process, the identification of a conversation, dummy answers for a missing or removed receiver, pool exhaustion, the operator's interrupt key, and semaphores rejected for "black sheep" (pp. 239 to 240); the limit on outstanding messages, the parent's storage and the risk of a conversation (p. 240); device handling and process control inside the nucleus, the uninterruptable mode, creation and removal in an interruptible process, the sizes of 4,800 and 6,200 words and the times of a send, a wait and a conversation (p. 241), the single processor implied and not stated, and the sizes read with less certainty than the times; the acknowledgement of Dijkstra (p. 250).
  9. S. Klabnik, C. Nichols and C. Krycho, The Rust Programming Language: §16.2, "Transfer Data Between Threads with Message Passing"; §16.3, "Shared-State Concurrency"; §16.4, "Extensible Concurrency with the Send and Sync Traits". A send moves ownership (§16.2); Arc and Mutex for shared state (§16.3); data races excluded in safe code, and manual Send and Sync implementations unsafe (§16.4).
  10. The Rust standard library, std::sync::Arc, https://doc.rust-lang.org/std/sync/struct.Arc.html, and std::sync::Mutex, https://doc.rust-lang.org/std/sync/struct.Mutex.html. An Arc shares its data and adds no thread safety to it; interior mutability through Mutex, RwLock or an atomic type (the text's OnceLock is not named there).
  11. A. D. Birrell and B. J. Nelson, Implementing Remote Procedure Calls, ACM Transactions on Computer Systems 2(1), February 1984, 39–59. A call run "either once or not at all" after an exception (p. 49), duplicate call packets eliminated (p. 50).
  12. M. J. Fischer, N. A. Lynch and M. S. Paterson, Impossibility of Distributed Consensus with One Faulty Process, Journal of the ACM 32(2), April 1985, 374–382. Named as session 9's subject.
  13. J. Waldo, G. Wyant, A. Wollrath and S. Kendall, A Note on Distributed Computing, Sun Microsystems Laboratories, SMLI TR-94-29, November 1994. Partial failure (§4.3), named as session 9's subject.
  14. T. Tu, X. Liu, L. Song and Y. Zhang, Understanding Real-World Concurrency Bugs in Go, ASPLOS 2019, 865–878, doi 10.1145/3297858.3304069; read in the authors' copy, whose fourteen pages are numbered here by position (proceedings page 864 + n). The uses of each primitive (§3.2); 171 bugs in six systems; blocking bugs and their causes (pp. 6 to 7); non-blocking bugs (pp. 10 to 11); message passing "does not necessarily make" programs less error-prone (§7, "Discussion and Future Work").
  15. R. Milner, J. Parrow and D. Walker, A Calculus of Mobile Processes, I, Information and Computation 100(1), September 1992, 1–40, doi 10.1016/0890-5401(92)90008-4. Channel names as values sent on channels, and the authors' term mobility.
  16. G. R. Andrews and F. B. Schneider, Concepts and Notations for Concurrent Programming, ACM Computing Surveys 15(1), March 1983, 3–43. Message passing defined, and direct naming (p. 25); the port, one receiver and many senders (pp. 26 to 27); the three kinds of send and the assertions a sender can make after each (p. 27); send and receive in guards an open problem (p. 29).
  17. S. Fowler, S. Lindley and P. Wadler, Mixing Metaphors: Actors as Channels and Channels as Actors, ECOOP 2017, LIPIcs 74, 11:1–11:28, doi 10.4230/LIPIcs.ECOOP.2017.11. Typed translations between a calculus of asynchronous channels and a calculus of actors; input-guarded choice added to the channel calculus, its emulation in the actor calculus left to future work (§7.3, §9).
  18. C. Palamidessi, Comparing the Expressive Power of the Synchronous and the Asynchronous π-calculus, POPL 1997, 256–265; read in the author's copy. No uniform encoding of mixed choice into the asynchronous π-calculus; the uniformity criterion (§6).
  19. U. Nestmann and B. C. Pierce, Decoding Choice Encodings, CONCUR 1996, LNCS 1119, 179–194; read in the revised full version, BRICS RS-99-42 (Information and Computation 163(1), 2000). Input-guarded choice encoded in the asynchronous π-calculus.
  20. E. A. Lee, The Problem with Threads, IEEE Computer 39(5), May 2006, 33–42; read as UCB/EECS-2006-1, 10 January 2006. Threads "wildly nondeterministic" (p. 5), Kahn networks deterministic and "NondeterministicMerge" (p. 11), nondeterminism introduced where needed (p. 15).
  21. E. A. Lee and T. M. Parks, Dataflow Process Networks, Proceedings of the IEEE 83(5), May 1995, 773–801; read in the preprint of 27 March 1995, whose section numbers are used. Kahn process networks (§2.1) and networks of monotonic processes determinate (§2.2); the five ways to add nondeterminism (§2.2); sequential processes with blocking reads continuous (§2.4.6).
  22. P. Van Roy and S. Haridi, Concepts, Techniques, and Models of Computer Programming, MIT Press, 2004; checked at its table of contents. Chapter 4, "Declarative Concurrency"; chapter 5, "Message-Passing Concurrency"; §11.8, "Partial failure".
  23. P. Van Roy, LINFO1131, lecture 5, Limitations of declarative programming, UCLouvain, 13 October 2021. Ports added "to overcome the limitations of declarative programming" (slide 24); the order of requests "cannot be determined in advance" (slide 14).