@@ -14,27 +14,36 @@
14\newcommand{\sLink}{\mathtt{link}}
14\newcommand{\sLink}{\mathtt{link}}
15\newcommand{\sThrow}{\mathtt{throw}}
15\newcommand{\sThrow}{\mathtt{throw}}
16\newcommand{\sReconnect}{\mathtt{reconnect}}
16\newcommand{\sReconnect}{\mathtt{reconnect}}
17+\newcommand{\sNewChan}{\mathtt{newChan}}
18+\newcommand{\sSendChan}{\mathtt{sendChan}}
19+\newcommand{\sReceiveChan}{\mathtt{receiveChan}}
20+\newcommand{\sMonitor}{\mathtt{monitor}}
22+\DeclareMathOperator{\sNodeOf}{node}
23+\DeclareMathOperator{\sProcessOf}{process}
18\newcommand{\sSpawned}{\mathtt{spawned}}
25\newcommand{\sSpawned}{\mathtt{spawned}}
20\newcommand{\sExtend}[1]{\mathrel{\triangleright_{#1}}}
27\newcommand{\sExtend}[1]{\mathrel{\triangleright_{#1}}}
22\newcommand{\sPar}{\mathrel{\parallel}}
29\newcommand{\sPar}{\mathrel{\parallel}}
23−\newcommand{\sParN}{\mathrel{{\parallel}_N}}
24\newcommand{\sProc}[2]{{#1}_{#2}}
30\newcommand{\sProc}[2]{{#1}_{#2}}
26−\newcommand{\sPid}{\ensuremath{\mathit{pid}}}
27\newcommand{\sNid}{\ensuremath{\mathit{nid}}}
32\newcommand{\sNid}{\ensuremath{\mathit{nid}}}
33+\newcommand{\sPid}{\ensuremath{\mathit{pid}}}
34+\newcommand{\sCid}{\ensuremath{\mathit{cid}}}
28\newcommand{\sId}{\ensuremath{\mathit{id}}}
36\newcommand{\sId}{\ensuremath{\mathit{id}}}
29\newcommand{\sRef}{\ensuremath{\mathit{ref}}}
37\newcommand{\sRef}{\ensuremath{\mathit{ref}}}
31\newcommand{\sLinks}{\ensuremath{\mathit{links}}}
39\newcommand{\sLinks}{\ensuremath{\mathit{links}}}
32\newcommand{\sNode}[3]{\left[{#1} ; {#2}\right]_{#3}}
40\newcommand{\sNode}[3]{\left[{#1} ; {#2}\right]_{#3}}
33−\newcommand{\sSystem}[3]{\left\langle #1 ; #2 ; #3 \right\rangle}
41+\newcommand{\sSystem}[4]{\left\langle #1 ; #2 ; #3 ; #4 \right\rangle}
34\newcommand{\sNodes}{\mathcal{N}}
42\newcommand{\sNodes}{\mathcal{N}}
35\newcommand{\sQueue}{\mathcal{Q}}
43\newcommand{\sQueue}{\mathcal{Q}}
36\newcommand{\sProcesses}{\mathcal{P}}
44\newcommand{\sProcesses}{\mathcal{P}}
37\newcommand{\sBlacklist}{\mathcal{B}}
45\newcommand{\sBlacklist}{\mathcal{B}}
46+\newcommand{\sMonitors}{\mathcal{M}}
39\newcommand{\sJust}[1]{\mathtt{Just} \; {#1}}
48\newcommand{\sJust}[1]{\mathtt{Just} \; {#1}}
40\newcommand{\sNothing}{\mathtt{Nothing}}
49\newcommand{\sNothing}{\mathtt{Nothing}}
@@ -73,13 +82,21 @@
74\subsection{Processes, Nodes, Systems}
83\subsection{Processes, Nodes, Systems}
76−We assume two disjoint enumerable sets $\mathtt{ProcessId}$ and
85+We assume disjoint countable sets $\mathtt{NodeId}$, $\mathtt{ProcessId}$, and
77−$\mathtt{NodeId}$, ranged over by $\sPid$ and $\sNid$ and representing process
86+$\mathtt{ChannelId}$, changed over by \sNid, \sPid{} and \sCid{} respectively,
78−identifiers and node identifiers respectively. We do not need to refer to nodes
87+and representing process identifiers, node identifiers, and (typed) channel
79−as entities in their own right in the semantics, but simply assume a total
88+identifiers. We assume the existence of total functions
91+\begin{array}{r@{\;:\;}l}
80−function $$\mathtt{node} : \mathtt{ProcessId} \rightarrow \mathtt{NodeId}$$ We
92+\sNodeOf & (\mathtt{ProcessId} \uplus \mathtt{ChannelId}) \rightarrow \mathtt{NodeId} \\
93+\sProcessOf & \mathtt{ChannelId} \rightarrow \mathtt{ProcessId}
81−also define $\mathtt{Identifier} = \mathtt{ProcessId} \uplus \mathtt{NodeId}$
98+$$\mathtt{Identifier} = \mathtt{NodeId} \uplus \mathtt{ProcessId} \uplus \mathtt{ChannelId}$$
82−and let $\sId$ range over $\mathtt{Identifier}$.
99+and let $\sId$ range over $\mathtt{Identifier}$.
84We represent a process as a pair $\sProc{M}{\sPid}$ of a term $M$ and a process
101We represent a process as a pair $\sProc{M}{\sPid}$ of a term $M$ and a process
85ID $\sPid$. We will denote a set of processes as
102ID $\sPid$. We will denote a set of processes as
@@ -87,24 +104,34 @@ ID $\sPid$. We will denote a set of processes as
87 $$\sProc{M}{\sPid} \sPar \cdots \sPar \sProc{N}{\sPid'}$$
104 $$\sProc{M}{\sPid} \sPar \cdots \sPar \sProc{N}{\sPid'}$$
89A \emph{system}
106A \emph{system}
90− $\sSystem{\sProcesses}{\sQueue}{\sBlacklist}$
107+ $\sSystem{\sProcesses}{\sQueue}{\sBlacklist}{\sMonitors}$
91−finally is a tuple containing a set $\sProcesses$ of nodes,
108+finally is a tuple containing a set $\sProcesses$ of nodes, a \emph{system
92−a \emph{system queue} $\sQueue$, and a \emph{blacklist} $\sBlacklist$.
109+queue} $\sQueue$, a \emph{blacklist} $\sBlacklist$, and a set of monitors
112+The set of monitors $\sMonitors$ is a set of tuples
113+ $(\sId_\mathit{to}, \sPid_\mathit{fr}, \sNid, \sRef)$
114+which records that the node controller at \sNid is aware that process
115+$\sPid_\mathit{fr}$ is monitoring $\sId_\mathit{to}$.
94The system queue is a set of triples $(\sId_\mathit{to}, \sId_\mathit{fr},
117The system queue is a set of triples $(\sId_\mathit{to}, \sId_\mathit{fr},
95\mathit{message})$ of messages that have been sent but not yet processed. The
118\mathit{message})$ of messages that have been sent but not yet processed. The
96blacklist records disconnections and is represented as a of pairs
119blacklist records disconnections and is represented as a of pairs
97$(\sId_\mathit{to}, \sId_\mathit{fr})$.
120$(\sId_\mathit{to}, \sId_\mathit{fr})$.
122+Note that we do not need to refer to nodes as entities in their own right in
99\section{Semantics}
125\section{Semantics}
101\subsection{Contexts}
127\subsection{Contexts}
103We define an evaluation context as usual (TODO: catch?)
129We define an evaluation context as usual (TODO: catch?)
105−\begin{equation*}
131+\begin{align*}
106−\sCtxt{E} ::= [] \OR \sBind{\sCtxt{E}}{M}
132+\sCtxt{E} & ::= [] \OR \sBind{\sCtxt{E}}{M} \\
107−\end{equation*}
133+\sCtxt{P}_\sPid & ::= \sCtxt{E}[]_\sPid \sPar \sProcesses
109\subsection{Disconnect}
136\subsection{Disconnect}
@@ -123,10 +150,19 @@ processes $\sProcesses$, such that
125\sPid \in \sProcesses \qquad
152\sPid \in \sProcesses \qquad
126−\mathtt{node}(\sPid) = \sNid
153+\sNodeOf(\sPid) = \sNid
128\sPid \in \overline{\sNid}
155\sPid \in \overline{\sNid}
161+\sCid \in \sProcesses \qquad
162+\sNodeOf(\sCid) = \sNid
164+\sCid \in \overline{\sNid}
130\end{equation*}
166\end{equation*}
132The following rule models random network disconnect between nodes $\sNid_1$ and
168The following rule models random network disconnect between nodes $\sNid_1$ and
@@ -135,28 +171,45 @@ $\sNid_2$:
135\begin{equation*}
171\begin{equation*}
138− \sSystem{\sProcesses}{\sQueue}{\sBlacklist}
174+ \sSystem{\sProcesses}{\sQueue}{\sBlacklist}{\sMonitors}
139\rightarrow
175\rightarrow
140− \sSystem{\sProcesses}{\sQueue}{\sBlacklist \cup (\overline{\sNid_1} \times \overline{\sNid_2})}
176+ \sSystem{\sProcesses}{\sQueue}{\sBlacklist \cup (\overline{\sNid_1} \times \overline{\sNid_2})}{\sMonitors}
141} \textsc{Disconnect}
177} \textsc{Disconnect}
142\end{equation*}
178\end{equation*}
180+We provide a primitive to remove a connection from the blacklist:
185+ \sSystem{\sCtxt{P}[ \sReconnect \; \sId_\mathit{to} ]_{\sPid_\mathit{fr}}}
190+ \sSystem{\sCtxt{P}[ \sReturn \; () ]_\sPid}
192+ {\sBlacklist \backslash (\sPid_\mathit{to}, \sPid_\mathit{fr})}
144−However, connections to and from nodes can be implicitly reconnected:
197+Connections to and from nodes can be implicitly reconnected:
146\begin{equation*}
199\begin{equation*}
149− \sSystem{\sProcesses}{\sQueue}{\sBlacklist, (\sNid_\mathit{to}, \sId_\mathit{fr})}
202+ \sSystem{\sProcesses}{\sQueue}{\sBlacklist, (\sNid_\mathit{to}, \sId_\mathit{fr})}{\sMonitors}
150\rightarrow
203\rightarrow
151− \sSystem{\sProcesses}{\sQueue}{\sBlacklist}
204+ \sSystem{\sProcesses}{\sQueue}{\sBlacklist}{\sMonitors}
152−} \textsc{Recon-To}
205+} \textsc{Recon-Im1}
156− \sSystem{\sProcesses}{\sQueue}{\sBlacklist, (\sId_\mathit{to}, \sNid_\mathit{fr})}
209+ \sSystem{\sProcesses}{\sQueue}{\sBlacklist, (\sId_\mathit{to}, \sNid_\mathit{fr})}{\sMonitors}
157\rightarrow
210\rightarrow
158− \sSystem{\sProcesses}{\sQueue}{\sBlacklist}
211+ \sSystem{\sProcesses}{\sQueue}{\sBlacklist}{\sMonitors}
159−} \textsc{Recon-Fr}
212+} \textsc{Recon-Im2}
160\end{equation*}
213\end{equation*}
162Once a connection has been blacklisted, no further messages can be sent across
215Once a connection has been blacklisted, no further messages can be sent across
@@ -179,45 +232,44 @@ introduce a function
179\end{array}
232\end{array}
180\end{equation*}
233\end{equation*}
182\subsection{Process rules}
237\subsection{Process rules}
184−\subsubsection{Sending}
239+\subsubsection{Send and Receive}
186−If the communication is blacklisted the send is a no-op.
241+We ignore issues of serializability for the purposes of this semantics.
188\begin{equation*}
243\begin{equation*}
191− \sSystem{ \sCtxt{E}[ \sSend \; \sPid_\mathit{to} \; M ]_{\sPid_\mathit{fr}}
246+ \sSystem{\sCtxt{P}[ \sSend \; \sPid_\mathit{to} \; M ]_{\sPid_\mathit{fr}}}
195 {\sQueue}
247 {\sQueue}
196 {\sBlacklist}
248 {\sBlacklist}
197\rightarrow
250\rightarrow
198− \sSystem{\sCtxt{E}[ \sReturn \; () ]_\mathit{fr} \sPar \sProcesses}
251+ \sSystem{\sCtxt{P}[ \sReturn \; () ]_\mathit{fr}}
199 {\sQueue \sExtend{\sBlacklist} (\sPid_\mathit{to}, \sPid_\mathit{fr}, M)}
252 {\sQueue \sExtend{\sBlacklist} (\sPid_\mathit{to}, \sPid_\mathit{fr}, M)}
200 {\sBlacklist}
253 {\sBlacklist}
201} \textsc{Send}
255} \textsc{Send}
202\end{equation*}
256\end{equation*}
204−We ignore issues of serializability for the purposes of this semantics.
206−\subsubsection{Receiving}
208We return the \emph{first} message of a randomly chosen sender.
258We return the \emph{first} message of a randomly chosen sender.
210\begin{equation*}
260\begin{equation*}
212 \sId_{\mathit{fr}} \notin \sSenders(\sQueue)
262 \sId_{\mathit{fr}} \notin \sSenders(\sQueue)
214− \sSystem{\sCtxt{E}[ \sExpect ]_{\sPid_\mathit{to}} \sPar \sProcesses}
264+ \sSystem{\sCtxt{P}[ \sExpect ]_{\sPid_\mathit{to}}}
215 {\sQueue, (\sPid_\mathit{to}, \sId_\mathit{fr}, M), \sQueue'}
265 {\sQueue, (\sPid_\mathit{to}, \sId_\mathit{fr}, M), \sQueue'}
216 {\sBlacklist}
266 {\sBlacklist}
217\rightarrow
268\rightarrow
218− \sSystem{\sCtxt{E}[ \sReturn \; M ]_{\sPid_\mathit{to}} \sPar \sProcesses}
269+ \sSystem{\sCtxt{P}[ \sReturn \; M ]_{\sPid_\mathit{to}}}
219 {\sQueue, \sQueue'}
270 {\sQueue, \sQueue'}
220 {\sBlacklist}
271 {\sBlacklist}
221} \textsc{Expect}
273} \textsc{Expect}
222\end{equation*}
274\end{equation*}
@@ -227,48 +279,186 @@ Spawning is asynchronous
228\begin{equation*}
280\begin{equation*}
230− \text{\sRef fresh}
282+ \sRef \text{ fresh}
232− \sSystem{\sCtxt{E}[ \sSpawn \; \sNid \; M ]_\sPid \sPar \sProcesses}
284+ \sSystem{\sCtxt{P}[ \sSpawn \; \sNid \; M ]_\sPid}
233 {\sQueue}
285 {\sQueue}
234 {\sBlacklist}
286 {\sBlacklist}
235\rightarrow
288\rightarrow
236− \sSystem{\sCtxt{E}[ \sReturn \; \sRef ]_\sPid \sPar \sProcesses}
289+ \sSystem{\sCtxt{P}[ \sReturn \; \sRef ]_\sPid}
237 {\sQueue \sExtend{\sBlacklist} (\sNid, \sPid, \sSpawn \; \sRef \; M)}
290 {\sQueue \sExtend{\sBlacklist} (\sNid, \sPid, \sSpawn \; \sRef \; M)}
238 {\sBlacklist}
291 {\sBlacklist}
239} \textsc{Spawn-Async}
293} \textsc{Spawn-Async}
240\end{equation*}
294\end{equation*}
243\begin{equation*}
296\begin{equation*}
245 \sPid \notin \sSenders(\sQueue)
298 \sPid \notin \sSenders(\sQueue)
247− \text{$\sPid'$ fresh}
300+ \sPid' \text{ fresh}
302+ \sNodeOf(\sPid') = \sNid
249 \sSystem{\sProcesses}
304 \sSystem{\sProcesses}
250 {\sQueue, (\sNid, \sPid, \sSpawn \; \sRef \; M), \sQueue'}
305 {\sQueue, (\sNid, \sPid, \sSpawn \; \sRef \; M), \sQueue'}
251 {\sBlacklist}
306 {\sBlacklist}
252\rightarrow
308\rightarrow
253 \sSystem{\sProcesses \sPar M_{\sPid'}}
309 \sSystem{\sProcesses \sPar M_{\sPid'}}
254 {\sQueue, \sQueue' \sExtend{\sBlacklist} (\sPid, \sNid, \sSpawned \; \sRef \; \sPid')}
310 {\sQueue, \sQueue' \sExtend{\sBlacklist} (\sPid, \sNid, \sSpawned \; \sRef \; \sPid')}
255 {\sBlacklist}
311 {\sBlacklist}
256} \textsc{Spawn-Reply}
313} \textsc{Spawn-Reply}
257\end{equation*}
314\end{equation*}
259−\subsubsection{Reconnect}
316+\subsubsection{Typed Channels}
318+Since the semantics is not type-driven, we represent typed channels simply as
319+an identifier with an annotation whether it is the send-end ($\sCid^s$) or the
320+receive end ($\sCid^r$) of the channel.
261\begin{equation*}
322\begin{equation*}
326+ \sProcessOf(\sCid) = \sPid
264− \sSystem{\sCtxt{P}[ \sReconnect \; \sId_\mathit{to} ]_{\sPid_\mathit{fr}}}
328+ \sSystem{\sCtxt{P}[\sNewChan]_\sPid}
265 {\sQueue}
329 {\sQueue}
266 {\sBlacklist}
330 {\sBlacklist}
267\rightarrow
332\rightarrow
268− \sSystem{\sCtxt{P}[ \sReturn \; () ]_\sPid}
333+ \sSystem{\sCtxt{P}[\sReturn \; (\sCid^s, \sCid^r)]_\sPid}
269 {\sQueue}
334 {\sQueue}
270− {\sBlacklist \backslash (\sPid_\mathit{to}, \sPid_\mathit{fr})}
335+ {\sBlacklist}
343+ \sSystem{\sCtxt{P}[ \sSendChan \; \sCid_\mathit{to}^s \; M ]_{\sPid_\mathit{fr}}}
348+ \sSystem{\sCtxt{P}[ \sReturn \; () ]_{\sPid_\mathit{fr}}}
349+ {\sQueue \sExtend{\sBlacklist} (\sCid_\mathit{to}, \sPid_\mathit{fr}, M)}
271−} \textsc{Reconnect}
352+} \textsc{SendChan}
357+ \sId_{\mathit{fr}} \notin \sSenders(\sQueue)
359+ \sSystem{\sCtxt{P}[ \sReceiveChan \; \sCid^r ]_{\sPid}}
360+ {\sQueue, (\sCid_\mathit{to}, \sPid_\mathit{fr}, M), \sQueue'}
364+ \sSystem{\sCtxt{P}[ \sReturn \; M ]_{\sPid}}
368+} \textsc{ReceiveChan}
371+\subsubsection{Monitoring}
375+ \sNid_\mathit{fr} = \sNodeOf(\sPid_\mathit{fr})
377+ \sNid_\mathit{to} = \sNodeOf(\sPid_\mathit{to})
382+& \sSystem{\sCtxt{P}[ \sMonitor \; \sId_\mathit{to} ]_{\sPid_\mathit{fr}}}
388+ \sSystem{\sCtxt{P}[ \sReturn \; \sRef ]_{\sPid_\mathit{fr}}}
389+ {\sQueue \sExtend{\sBlacklist} (\sNid_\mathit{to}, \sPid_\mathit{fr}, \sMonitor \; \sRef \; \sId_\mathit{to})}
391+ {\sMonitors, (\sId_\mathit{to}, \sPid_\mathit{fr}, \sNid_\mathit{fr}, \sRef)}
398+ \sPid_\mathit{fr} \notin \sSenders(\sQueue)
400+ \sSystem{\sProcesses}
401+ {\sQueue, (\sNid_\mathit{to}, \sPid_\mathit{fr}, \sMonitor \; \sRef \; \sId_\mathit{to}), \sQueue'}
405+ \sSystem{\sProcesses}
408+ {\sMonitors, (\sId_\mathit{to}, \sPid_\mathit{fr}, \sNid_\mathit{to}, \sRef)}
409+} \textsc{Monitor-Remote}
414+ \sNid_\mathit{fr} = \sNodeOf(\sPid_\mathit{fr})
416+ \sSystem{\sProcesses}
418+ {\sBlacklist, (\sId_\mathit{to}, \sPid_\mathit{fr})}
419+ {\sMonitors, (\sId_\mathit{to}, \sPid_\mathit{fr}, \sNid_\mathit{fr}, \sRef)}
421+ \sSystem{\sProcesses}
422+ {\sQueue, (\sPid_\mathit{fr}, \sId_\mathit{to}, \mathtt{disconnected} \; \sRef)}
423+ {\sBlacklist, (\sId_\mathit{to}, \sPid_\mathit{fr})}
428+\subsubsection{Process Termination}
432+ \sNodeOf(\sPid) = \sNid
434+ \nexists \; \sPid', \sRef \cdot (\sPid, \sPid', \sNid, \sRef) \in \sMonitors
436+ \sSystem{{(\sReturn \; ())}_\sPid \sPar \sProcesses}
441+ \sSystem{\sProcesses}
450+ \sNodeOf(\sPid) = \sNid
452+ \sSystem{{(\sReturn \; ())}_\sPid \sPar \sProcesses}
455+ {\sMonitors, (\sPid, \sPid', \sNid, \sRef)}
457+ \sSystem{{(\sReturn \; ())}_\sPid \sPar \sProcesses}
458+ {\sQueue \sExtend{\sBlacklist} (\sPid', \sPid, \mathtt{died} \; \sRef)}
272\end{equation*}
462\end{equation*}
274\subsubsection{Administration}
464\subsubsection{Administration}