PROGRAMMING PARADIGMS · PART 2 · SESSION 8, BLOCK 2

Message passing: actors, mailboxes and the delivery assumption

Block 2. Actors, mailboxes and the delivery assumption

When a send never waits and every message goes to the mailbox of one named receiver, what does the model guarantee about order and delivery, and what does sharing nothing cost?

The plan of the session

Block 1The RC 4000 nucleus (1969); shared memory and the scheduler; processes that share nothing; Kahn process networks; contested communications and three resolutions; the RC 4000's two resolutions; channels (CSP, occam, Go); buffer capacity.
Block 2Actors and mailboxes (Hewitt, Agha, Erlang); fairness; the delivery assumption and the boundary with session 9; the cost of message passing, and channels against actors.
The labA message-passing library built by the students: a toy RC 4000 nucleus, one queue under two disciplines, the handshake, select, and a closing comparison.
PART 7

Actors and mailboxes: asynchronous sends into a mailbox in arrival order

Hewitt 1973, Agha 1985, Erlang; the second family of message passing

The origins of arrival order in a queue

RC 4000, 1969operating systemsPQRmailbox Actors, 1973artificial intelligencePQRmailbox Erlang, 1986Ericsson; fault tolerancePQRmailbox

Arrival order in a queue, the third resolution of part 4, is the one the RC 4000 gave for requests: senders put messages into one mailbox, and the order of arrival determines which is served first.

Actors, 1973. The actor model began in artificial intelligence, not in operating systems: Hewitt, Bishop and Steiger 1973, out of Hewitt's earlier work on Planner; as far as is known, independently of the RC 4000.

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” (page 236); “Every actor should act for himself or delegate the responsibility” (page 238).

Erlang, 1986. After the RC 4000 and the actors, Erlang reached the same answer at Ericsson, for another reason: fault tolerance.

Agha's actor primitives in OCaml

OCaml 5
toy_actor.mltype 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
let become a b = a.behaviour <- b

let run () =
  while not (Queue.is_empty mailroom) do
    let (a, m) = Queue.pop mailroom in
    a.behaviour m
  done

Agha 1985 gave actors the form in which they are taught today (De Koster et al. 2016, page 33): three primitives, here as a toy in OCaml.

create makes an actor from a behaviour and returns its address.

send sends asynchronously to an address and returns at once: the toy pushes the pair onto the mailroom and never waits.

become replaces the behaviour, so the next message is handled by the new one.

run takes one pending message at a time and calls its actor's behaviour on it: one turn, run to completion.

The counter actor and the toy's mailroom

OCaml 5
toy_actor.mllet rec counter n self = function
  | Int k -> become self (counter (n + k) self)
  | Ask reply -> send reply (Int n)
$ ocamlfind ocamlopt toy_actor.ml -o toy_actor
$ ./toy_actor
5

On Int k, the counter becomes a counter at n + k. On Ask reply, it sends its count to the address given. Two increments and an Ask print 5.

A send only enqueues. The sender continues at once; the message waits in the mailroom until run takes it.

Each delivery runs to completion, the Isolated Turn Principle of De Koster et al. 2016: within one turn there is no low-level data race and no deadlock (pages 33 to 34).

The counter has no mutable variable of its own. Its state lives in the behaviour it becomes next.

Arrival order. The toy takes the front, Queue.pop: one order only. The model's order is arbitrary; a random pick among the pending messages models it.

mailroom backfront run counter 0counter 2 Ask printer Int 3 Int 2

Actors compared with worker pools, objects and Erlang's processes

worker poolworkerworkerworkera common pile actorsactor Aactor Bactor Ca mailbox each object and actorcallerobjectcallreturnsenderactoraddressanswer by a send

An actor has its own identity, its own address and private state, and a mailbox of its own. Two familiar pictures misrepresent this, and both are wrong.

Not a worker pool, 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.

Not an object. An actor resembles an object that can be written to but never called: nothing returns, and a sender that needs an answer puts its own address in the message.

Classic actor and Erlang process. A classic actor is a handler that the runtime calls once per message; an Erlang process is a loop that blocks in receive (De Koster et al. 2016, pages 33, 35).

appendixthe RC 4000's loop, the classic actor's handler and Erlang's loop, drawn side by side

The guarantees of actor theory and their limits

Guaranteed

  • every message sent is eventually delivered, after an arbitrary but finite delay (Agha 1985, page 23);
  • a message arrives whole, an aim the model states rather than a guarantee it proves (page 20);
  • one turn is isolated: no low-level race or deadlock inside it (De Koster et al. 2016, pages 33–34);
  • a message is received only after it is sent (causality; Armstrong 2003, page 26);
  • an actor sends to the actors it is acquainted with (Hewitt 1973, page 236, as a metaphor).

Not guaranteed

  • arrival order, which is arbitrary (Agha 1985, page 22);
  • a bound on the delay;
  • a reply;
  • that a delivered message is "meaningfully processed" (pages 23 to 24);
  • freedom from races and deadlocks across several messages (De Koster et al. 2016, page 34).
appendixdelivery in TCP and in the actor model, and Agha's infinite stack

Agha's and Armstrong's arguments for asynchronous sends

no action at a distancesenderreceiverreadiness learned by a send fault isolationsenderfaulty receiver a synchronous send would block the sender send and pray

Agha 1985 (pages 19 to 22): “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.

Armstrong 2003, from fault isolation: “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” (page 23).

Delivery is then not guaranteed, across nodes or to a dead process; Armstrong calls the result “send and pray” (page 25).

appendixAgha's three reasons, and Armstrong's four steps with their two gaps, on two slides

Message order per pair of processes

sent by A a1a2 sent by B b1b2 one order at Ra1b1a2b2 another order at Rb1b2a1a2

Erlang adds back one guarantee, as “a design decision”: messages between a given pair of processes arrive in the order sent, for ordinary messages in the default mailbox (Armstrong 2003, page 25).

A's two messages arrive in the order A sent them, and B's in the order B sent them.

Across different senders Erlang guarantees no order: how their messages interleave depends on the scheduling.

Mailbox semantics in Erlang

$ escript mailbox.erl
1. the send returned; the message waits in the mailbox
   received: a send returns at once
2. arrival order: [{a,1},
                   {a,2},
                   {a,3},
                   {a,4},
                   {a,5},
                   {b,1},
                   {b,2},
                   {b,3},
                   {b,4},
                   {b,5}]
   a's own order kept: true; b's own order kept: true
3. the selective receive took {urgent, 3} past 'first' and 'second'
4. is_process_alive(Dead) = false; sending anyway
   the send returned its message; nothing reports the loss
5. the monitor delivered {'DOWN', Ref, process, Pid, because}

One recorded run of mailbox.erl, Erlang/OTP 29, for ordinary messages and the default mailbox.

1. A send returns before any process receives.

2. Each sender's own order is kept.

3. A selective receive takes a matching message from behind two earlier ones, so a mailbox is not a queue read from the front.

4. A send to the pid of a dead process returns normally, and nothing reports the loss.

appendixa send to a dead partner: a name no longer registered, the RC 4000's dummy answer, a monitor

The lost update across two messages

Erlang
counter.erlcounter(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.

The lost update of part 2 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, N.

Two clients each read it, then write it back plus one.

$ erlc counter.erl && erl -noshell -s counter start -s init stop
Erlang/OTP 29, ERTS 17.1, schedulers 12
run(3000): final value 1 (lost): 2953, final value 2: 47

The lost update and its repair, message by message

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

The counter process holds N = 0; two clients will each read it and write it back plus one.

Both clients send get; the two requests wait in the counter's mailbox in arrival order, client 1's first in this run.

The counter takes client 1's get and answers 0.

It takes client 2's get and answers 0 too: neither client has written yet.

Both clients send set 1, the value read plus one.

The counter takes the first set: N = 1.

It takes the second set: N = 1 again, after two increments.

The repair makes the increment one message: each client sends incr.

The counter's own sequential code applies both: N = 1, then 2.

The counter's own code is sequential; the race lies in the order in which its mailbox merges the two clients' messages.

A request and its reply in the RC 4000, Go and Erlang

RC 4000clientserverrequestclient's queuexb7the nucleus checks the identityGoclientserverrequestreply5replythe program keeps it, by conventionErlangclientserverrequestclient's mailbox{log}Refthe program keeps it, by convention

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}.

RC 4000: the request travels in buffer b7.

The answer comes back in the same buffer, into the client's queue behind x; wait answer(b7) takes it by its identity.

Go: the request carries a fresh channel, reply.

The server sends the answer on that channel, which, by convention, only the client reads.

Erlang: the request carries a fresh reference, Ref.

The answer comes back into the client's mailbox beside other messages, tagged with Ref, and the receive's pattern picks it out.

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 the program, by convention; in Erlang the client's own pattern.

appendixthe Erlang client's code: a request with a reference, a selective receive with a timeout

Message order in the systems of the story

ModelOrder
Go channela first-in-first-out queue: with one sender and one receiver, values are received in the order sent; no order among concurrent senders (the Go specification)
CSP 1978no queue; each exchange is one event between two sequential processes, so the exchanges of a pair are ordered; choice among senders arbitrary (Hoare 1978)
Actor theoryarbitrary (Agha 1985)
Erlangper pair of processes (Armstrong 2003), for ordinary messages and the default mailbox; with priority messages enabled (OTP 28.0 and later), two messages of one sender can stand in the queue out of their sending order; selective receive can take a later message first (the Erlang reference manual)
RC 4000one queue per process; two primitives allow any order (Brinch Hansen 1970)
appendixthe figure of sending, arrival and receiving order: Erlang, a Go channel, the actor model

The data carried by a message

senderreceiverErlangdatasend: a copydataGoacctsend: the pointeracctAccountone struct, sharedRustmovedsend: ownership movesv

What a message carries also differs between the systems: one sender, one receiver and one send, in three languages.

Erlang copies the data of a message, except reference-counted binaries and literals, which are shared on one node (the efficiency guide, "Processes").

A Go channel passes the value it is given, so a sent pointer stays shared.

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 shared (the Rust book, 16.2 and 16.3; std::sync::Arc).

appendixduplicates across a network, and the remote procedure call of Birrell and Nelson

Summary of part 7

The actor family, as the section has settled it:

The sendreturns at once, into the mailbox of one named receiver
The order of arrivalleft arbitrary by the model; fixed per pair of processes by Erlang, for ordinary messages
The deliveryassumed by the model
The racea race between messages, in place of the data race
Left to the next section: fairness, of which the assumed delivery is one form, and how the two families state it.
PART 8

Fairness: eventual choice and eventual delivery

CSP (1978), actor theory and Erlang's manual

Fairness in CSP and in actor theory

CSP: a choice between offersXYstop()X passed over foreverincrement the countercounter: 1, 2, 3, …
Actor theory: eventual deliverysendercountereventual deliverystopincrementhaltshalts at01234567…

Fairness concerns whether a ready communication eventually happens: a question of choice in CSP, which has no messages in transit, and of delivery in actor theory.

Hoare's example. X sends stop() while Y loops, either receiving the stop or incrementing a counter.

An unfair implementation. An implementation that always prefers the counter passes X over forever.

Hoare's refusal. The language does not 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” (Hoare, 1978, page 676).

Clinger's example. In actor theory, the guarantee of eventual delivery is a fairness assumption: a counter increments until a “stop” message arrives.

Unbounded nondeterminism. The stop is guaranteed to arrive, so the counter always halts, but at any number at all: a program certain to terminate, with infinitely many possible results.

Delivery and loss in CSP, actor theory and Erlang

CSP, Hoare 1978Actor theory, Agha 1985Erlang, to a live process on the same node (the manual)Erlang, to a dead process or another node (Armstrong 2003)
A ready message is eventually taken or deliverednot guaranteedguaranteedarrives after a positive time, unless the receiver has terminated or the alias is inactivenot guaranteed
A message can be lostno such thing existsno, by assumptiononly one sent through an inactive alias, dropped before the queueyes
The last column of the table, a dead process or another node, is where delivery itself can fail.
appendixwhat Go's specification states of a select, and Erlang's manual of arrival, two slides
PART 9

The delivery assumption: the boundary with session 9

Delivery on one node, a death reported where requested, and what session 9 changes

The delivery assumption

one nodePRsend to a live processreaches the queuemhandling: R’s own doingPRinactive alias: droppedPmonitorDOWNPplain send: no report

Delivery on one node. This session assumes delivery between the processes of one node.

Arrival. Every message sent to a live process reaches its queue.

The one exception. A message sent through an inactive alias is dropped before the queue.

Handling. Whether the process handles the message is its own doing.

A death reported where requested. The runtime reports a death exactly where the program requests the report: an Erlang monitor turns it into a DOWN message (the module erlang, monitor/2); the RC 4000’s nucleus returned a dummy answer (Brinch Hansen, 1970, pages 239 to 240).

A plain send. A plain send to a dead process reports nothing.

A teaching assumption. The RC 4000’s paper states it for a live receiver on one machine (Brinch Hansen, 1970); neither Erlang’s manual nor Go’s specification states it as such.

appendixa death reported on one runtime: the RC 4000's nucleus, Erlang's monitor, a plain send

The boundary with session 9

session 8session 9delivery assumedon one nodea crash on one machine,through a link and a monitordeliverygiven upFLP · failure detectors · partial failure

What session 9 changes is the delivery assumption, not the number of machines.

The start of session 9. A crash on one machine, observed through a link and a monitor.

Delivery given up. Only then does session 9 give up delivery.

The subjects of session 9. The impossibility result of Fischer, Lynch and Paterson (1985), failure detectors and Waldo's partial failure (1994) belong there.

PART 10

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

the bug study of six Go systems; sharing let back in; the π-calculus and its two limits; channels against actors

The bug study of Tu, Liu, Song and Zhang

shared memory message passing blocking bugs (85) non-blocking bugs (86) about 42% about 58% about 80% about 20%

Tu, Liu, Song and Zhang studied 171 concurrency bugs in six Go systems (ASPLOS 2019).

"Contrary to the common belief that message passing is less error-prone", more blocking bugs came from message passing (page 6).

The study's other half points the other way: far fewer non-blocking bugs came from message passing (pages 10 to 11).

Read together, in the systems studied, message-passing bugs were mostly blocking and shared-memory bugs mostly non-blocking.

Consistency with the storyThe price of removing sharing is waiting.
Uses of each primitive (§3.2)Shared-memory primitives are used more often, so by the study's count message passing is even likelier to cause a blocking bug.
Open questionWhether message passing creates or prevents bugs overall.

Sharing through a sent pointer

Go
shared_pointer.gotype Account struct{ Balance int }

ch := make(chan *Account)
go func() {
    acct := <-ch
    fmt.Println("receiver reads the balance:",
        acct.Balance)
}()
acct := &Account{Balance: 100}
ch <- acct         // the pointer is sent
acct.Balance = 200 // a write after the send

Message passing can also fail the opposite way, by letting sharing back in.

A pointer sent on a channel stays shared.

The race detector, in an instrumented run, reports the write after the send.

"Share by communicating" is a convention, and a program can break it without the compiler detecting it.

$ go run -race shared_pointer.go
receiver reads the balance: 100
==================
WARNING: DATA RACE
Write at 0x00c000116048 by main goroutine:
  main.main()
Previous read at 0x00c000116048 by goroutine 7:
  main.main.func1()
Goroutine 7 (finished) created at:
  main.main()
==================
sender's final balance: 200
Found 1 data race(s)
appendixsharing after a send in safe Rust: what a send moves, what stays shared, what reopens the hole

Mutual encodings of channels and actors and their limits

P Q a the channel name a, sent on the channel c an actor's address sender sender actor one reader: the survey's port a channel sender sender actor receiver receiver an actor that holds a queue translations, in the calculi studied mixed choice: no uniform encoding fairness: carried across by neither translation

In Milner, Parrow and Walker's π-calculus (1992), channel names are values that can themselves be sent on channels.

An actor's address is a channel with exactly one reader, the survey's port (Andrews and Schneider 1983, page 26).

A channel can in turn be written as an actor that holds a queue.

In the calculi studied, each family can be translated into the other (asynchronous channels without choice, in Fowler, Lindley and Wadler 2017), with what a translation preserves depending on it.

Mixed choice, a choice that waits on a send and a receive at once, has no uniform encoding in the asynchronous π-calculus (Palamidessi 1997); a choice among inputs only can be encoded (Nestmann and Pierce 1996), and Go's select offers mixed choice.

No fairness assumption is carried across by the translations studied: Go's channels guarantee no eventual delivery, actor theory assumes it (Agha 1985), so fairness has to be assumed on each side separately.

appendixthe two limits for the calculi, Go and actors, as a table; mixed choice in the survey of 1983 and Palamidessi's criterion

Actors and channels compared

Channel (Go)Actor (Erlang)
A send addressesa conduit, independent of processesa specific actor
Who readsany process holding itonly the owner
Several sourcesthe receiver chooses (select)one mailbox; patterns select messages
Resolution of a contested communicationa guarded choice in the program; a merge left to the schedulerarrival order in the mailbox
Bufferoften bounded (backpressure)conceptually unbounded
Failurenot in the model (Go)usually built in (Erlang)
Across machinesusually localaddresses often work across nodes
The RC 4000 (1969)its replies: identified, not contestedits requests: one queue, served in arrival order
appendixthe RC 4000's nucleus drawn: its request queue, its identified replies, the two blocks as their full forms

Summary of block 2

no contested meeting point Kahn's networks A B R the contest written down CSP, Go A B R the contest settled by merging RC 4000, actors, Erlang A B R shared memory shared memory shared memory one trusted place in each runtime, on one node waits waits waits

Message passing does not abolish the scheduler: it confines the scheduler's choices that can reach the results to the meeting points.

This holds as long as processes share nothing by any other route, messages carry values, the runtime delivers them as part 9 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.

appendixearlier accounts of the lecture's argument: Lee, Lee and Parks, Van Roy and Haridi, Fowler, Lindley and Wadler
APPENDIX

Details of block 2

supporting slides, each reached by the appendix button of a slide of the lecture, each with a button back

The RC 4000 process, the classic actor and the Erlang process

RC 4000 processmailboxwaithandlewait, handle, wait again classic actormailboxruntimehandlerbecome: next behaviour Erlang processmailboxreceivehandleloop(State)

An RC 4000 process is a thread in a loop beside its mailbox: wait, handle, wait again.

A classic actor inverts that structure: no loop, never waits; 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.

An Erlang process restores the loop: it loops, blocks in receive, and passes its state through recursion. That is the split between Classic Actors and the Processes family (De Koster et al. 2016, pages 33, 35).

back

Delivery in TCP and in the actor model

TCPactor model
orderkept per connectionnone guaranteed
deliveryobtained by retransmissionassumed

"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 limits (Agha 1985, page 23).

back

Agha's argument for asynchronous communication

no action at a distancesenderreceiverreadiness learned by a send a send to itselfactorneeds a buffer a fast sendertypisteditornot held to one character

Where the appendix of block 1 gives the reasons for the handshake, Agha 1985 argues the opposite (pages 19 to 22). “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.

back

Armstrong's argument from fault isolation and its gaps

1fault isolation 2share nothing 3asynchronous send 4delivery notguaranteed send and pray no timeout assumed the node's memory

Erlang, developed at Ericsson from 1986 with first experiments in 1987, arrived by an independent route at semantics like the actor model's: a design convergence, not a derivation from actor theory, with fault tolerance as its motive. Armstrong 2003 sets out the argument.

1. The essential problem in a fault-tolerant system is fault isolation: errors in a faulty module must not reach a correct one (page 17).

2. Any shared resource lets an error in one process corrupt it, so processes share nothing (pages 19, 23).

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” (page 23).

4. Delivery is not guaranteed, across nodes or to a dead process; the sender can learn that a message arrived only from a confirmation sent back (pages 22–23).

Armstrong calls the result “send and pray” (page 25).

No timeout. Step 3 assumes a synchronous send with no timeout, which a timed send would bound.

One shared resource left. An unbounded mailbox leaves the node's memory, which a stuck receiver's mailbox can exhaust for every process. Armstrong concedes a version of this himself, for operating-system processes that share one CPU and one memory, calling isolation “only true to a first approximation” (page 17).

back

A send to a dead partner, in Erlang and on the RC 4000

SendOutcome
Erlang, to the pid of a dead processreturns normally; nothing reports the loss
Erlang, to a name no longer registeredraises badarg (registered_send.erl, run on record, OTP 29)
RC 4000a dummy answer
Erlang, with a monitorthe partner's death becomes an ordinary message in the mailbox, {'DOWN', Ref, process, Pid, Reason} (the Erlang reference manual)
back

The reply matched by a reference

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

The mailbox that merges requests also receives replies.

The request carries a unique reference, Ref, in place of the RC 4000's buffer identity.

The reply comes back into the same mailbox as every other message; the selective receive finds it by Ref.

The program's pattern checks the identity, where on the RC 4000 the nucleus checked it.

back

Sending order, arrival order and receiving order

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

One process sends itself first, second and {urgent, 3}.

Erlang keeps the order between one sender and one receiver for ordinary messages: they arrive in the order sent, so the lines run straight.

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.

A Go channel with one sender and one receiver: the order sent is the order received, and nothing crosses.

The actor model leaves arrival order arbitrary: any of the six orders may arrive, three drawn here.

back

Duplicates across a network

one nodesenderreceivermone arrivalacross a networkcallercalleecallcallretrycallduplicatesuppressed

On one node, nothing in the systems of this section creates duplicates.

Duplicates arrive with retries across a network.

The remote procedure call protocol of Birrell and Nelson (1984) suppressed them.

After an exception, the call had run "either once or not at all—the user is not told which" (Birrell and Nelson 1984, p. 49).

back

Go's select and eventual service

runs of one select123456ready case aready case bready case ctaken eventually, with probability 1, under two assumptions

The rule of the specification. Each time a select runs, one of its ready cases is chosen by uniform pseudo-random selection (the Go specification, “Select statements”).

An inference, with probability 1. A case that stays ready is taken eventually, if the choices are independent and the goroutine runs the select again and again while the case stays ready.

Not stated by the specification. Eventual service of a ready case, and any order among blocked senders on one channel.

back

Arrival in Erlang's manual

PRarrives after a positive timein the queue; handling is R’s own doingmPRreceiver terminated, or channel downPRinactive alias: dropped before the queuePRone pair, two nodes: order keptm2m1

Arrival. A signal to a process arrives after an unspecified but positive time (the Erlang/OTP reference manual, “Processes”).

The named exceptions. A terminated receiver; a distribution channel that goes down.

The inactive alias. A message sent through an inactive alias is dropped before it enters the queue.

Arrival without handling. Arrival says nothing about the process handling the message.

Order per pair. The order between one pair of processes is kept, even across nodes.

back

A death reported on one runtime

RC 4000 nucleusErlang monitorplain send in ErlangSRnucleusdummy answerPRmonitorDOWNPno report

On one runtime, a death can be reported exactly.

The RC 4000. The nucleus returned a dummy answer (Brinch Hansen, 1970, pages 239 to 240).

Erlang. A monitor turns a death into a DOWN message (the module erlang, monitor/2).

A plain send. A plain send to a dead process reports nothing.

back

Sharing after a send in safe Rust

Safe Rust closes the data-race hole, not the sharing (The Rust Programming Language, chapter 16; std::sync::Arc).

A sendmoves ownership
What stays sharedan Arc, mutated only through a type that synchronizes its own access:
a Mutex
an RwLock
an atomic
a OnceLock
Safe codethe type system forbids unsynchronized conflicting accesses, not shared state
Unsound unsafe codereopens the hole
back

Limits of the mutual encodings of channels and actors

Mixed choice: a choice that waits on a send and a receive at once.

Mixed choiceFairness
The calculi studiedno uniform encoding in the asynchronous π-calculus that preserves a reasonable semantics (Palamidessi 1997); a choice among inputs only can be encoded (Nestmann and Pierce 1996)no fairness assumption carried across by the translations studied
Goselect offers itchannels guarantee no eventual delivery
Actorspure actors cannot express it directlyeventual delivery assumed (Agha 1985, page 23)
Fairness has to be assumed on each side separately.
back

Mixed choice in the survey of 1983

the survey (1983), page 29 send and receive statements in the same guards: “an active research area” the lecture's link Palamidessi (1997) no uniform encoding of mixed choice uniformity (§6): a distributed implementation without a central coordinator

Mixed choice is the problem of send and receive statements in the same guards, which the 1983 survey called "an active research area" (Andrews and Schneider, page 29).

Palamidessi's uniformity criterion models a distributed implementation without a central coordinator (§6); reading the survey's problem as that requirement is the lecture's own link.

back

The RC 4000 compared with actors and channels

RC 4000 nucleus (1969) P requests: one queue, served in arrival order S P buffer replies: identified, not contested the actor column the request half a channel the identified reply

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.

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.

back

Earlier accounts of the lecture's argument

Lee (2006), The Problem with Threadsthreads "wildly nondeterministic" (page 5); Kahn networks deterministic by their blocking reads (page 11)
nondeterminism "explicit in programs" (page 15), for example an explicit "NondeterministicMerge" (page 11)
Lee and Parks (1995), Dataflow Process Networks§2.2: the ways nondeterminism enters a Kahn network, the table in the appendix of block 1
Van Roy and Haridi (2004), CTM, chapters 4 to 5deterministic dataflow first, then ports, since in client/server "the order of the requests cannot be determined in advance" (UCLouvain's LINFO1131, lecture 5)
Fowler, Lindley and Wadler (2017)typed translations between asynchronous channels without choice and actors; input-guarded choice added, its emulation by actors left open
The lecture's additionthe RC 4000
the resolution of a contest as the comparison's axis
back