Skip to content

Commit c28e637

Browse files
author
admin
committed
revisions to chapter 4
1 parent f9edb5f commit c28e637

File tree

6 files changed

+140
-96
lines changed

6 files changed

+140
-96
lines changed

Chapters/chap2.tex

+16-16
Original file line numberDiff line numberDiff line change
@@ -608,44 +608,44 @@ \section{Extended Example: Memory Cells}\label{secmemcells}
608608

609609
We use the short hand $l?lock.P$ to mean:
610610
\[
611-
\rec{q}(\receive{l}{x} \pif{x=true}\pthen (P\comp \send{l}{\mbox{\emph{false}}})\pelse(q \comp \send{l}{\mbox{\emph{false}}}))
611+
\rec{q}(\receive{l}{x} \pif{x=\ptrue}\pthen (P\comp \send{l}{\pfalse})\pelse(q \comp \send{l}{\pfalse}))
612612
\]
613-
Above we check the lock channel $l$ and execute $P$ if it is currently set to $true$ (meaning the lock is still available).
613+
Above we check the lock channel $l$ and execute $P$ if it is currently set to $\ptrue$ (meaning the lock is still available).
614614
Otherwise we recursively try to get the lock again.
615-
Notice that whether the lock is already set to $\mbox{\emph{false}}$ or we are able to acquire it, we need to send $\mbox{\emph{false}}$ to $l$ so that another process can't acquire the lock.
615+
Notice that whether the lock is already set to \pfalse or we are able to acquire it, we need to send\pfalse to $l$ so that another process can't acquire the lock.
616616

617617
Let's use action semantics to make sure locking behaves as expected.
618618
We first note using (A-REP) that the above can internally evolve over $\tau$ to
619619
\begin{equation}\begin{split}
620-
\evolves{\tau} & \receive{l}{x} \pif{x=true}\pthen(P\comp \send{l}{\mbox{\emph{false}}})\pelse\\
621-
&l?lock.P \comp \send{l}{\mbox{\emph{false}}}))
620+
\evolves{\tau} & \receive{l}{x} \pif{x=\ptrue}\pthen(P\comp \send{l}{\pfalse})\pelse\\
621+
&l?lock.P \comp \send{l}{\pfalse}))
622622
\end{split}\end{equation}
623-
If $\receive{l}{x}$ receives a true, then
623+
If $\receive{l}{x}$ receives a \ptrue, then
624624
\begin{equation}\begin{split}
625-
\evolves{\receives{c}{true}} & \pif{true=true}\pthen(P\comp \send{l}{\mbox{\emph{false}}})\pelse\\
626-
&l?lock.P \comp \send{l}{\mbox{\emph{false}}}))
625+
\evolves{\receives{c}{\ptrue}} & \pif{\ptrue=\ptrue}\pthen(P\comp \send{l}{\pfalse})\pelse\\
626+
&l?lock.P \comp \send{l}{\pfalse}))
627627
\end{split}\end{equation}
628628
We can now apply (A-EQ), yielding:
629629
\begin{equation}\begin{split}
630-
\evolves{\tau} & P\comp \send{l}{\mbox{\emph{false}}}\\
630+
\evolves{\tau} & P\comp \send{l}{\pfalse}\\
631631
\end{split}\end{equation}
632-
As expected. Otherwise, if $\receive{l}{x}$ receives a \mbox{\emph{false}}, then $l?lock.P$
632+
As expected. Otherwise, if $\receive{l}{x}$ receives a \pfalse, then $l?lock.P$
633633
\begin{equation}\begin{split}
634-
\evolves{\receives{c}{\mbox{\emph{false}}}} & \pif{\mbox{\emph{false}}=true}\pthen(P\comp \send{l}{\mbox{\emph{false}}})\pelse\\
635-
&l?lock.P \comp \send{l}{\mbox{\emph{false}}}))
634+
\evolves{\receives{c}{\pfalse}} & \pif{\pfalse=\ptrue}\pthen(P\comp \send{l}{\pfalse})\pelse\\
635+
&l?lock.P \comp \send{l}{\pfalse}))
636636
\end{split}\end{equation}
637637
This time using (A-NEQ),
638638
\begin{equation}\begin{split}
639-
\evolves{\tau} &l?lock.P \comp \send{l}{\mbox{\emph{false}}}))
639+
\evolves{\tau} &l?lock.P \comp \send{l}{\pfalse}))
640640
\end{split}\end{equation}
641641
Which again is what we would expect.
642642
Thus, we have verified that the lock works as expected.\todo{line up all the above equations by putting them in one array and using breaks}
643643

644644
Now, unlocking is done via the shorthand $l!unlock$, meaning
645645
\[
646-
\receive{l}{x} \send{l}{true}
646+
\receive{l}{x} \send{l}{\ptrue}
647647
\]
648-
This term simply discards the current $l$ value and sets it to $true$.
648+
This term simply discards the current $l$ value and sets it to $\ptrue$.
649649

650650
Our $MemoryClient$ thus becomes:
651651
\begin{equation}\begin{split}
@@ -654,5 +654,5 @@ \section{Extended Example: Memory Cells}\label{secmemcells}
654654
&\comp \receive{a_2}{z}(l!unlock\comp \send{o}{z}))))
655655
\end{split}\end{equation}
656656
Note that the lock $l$ is exposed.
657-
It needs to be initialized to $true$ by the system that defines it so that the first process trying to get the lock can get it.
657+
It needs to be initialized to $\ptrue$ by the system that defines it so that the first process trying to get the lock can get it.
658658
We will return to the subject of locks in Chapter \ref{sync_and_dist_sys}, where they play a surprisingly similar role in the implementation of a synchronous \picalc.

Chapters/chap3.tex

+16-15
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ \section{The Synchronous \Picalc}\label{Synchronous picalc}
101101
\new{c}\new{d} P \ &\ \sequiv\ \new{d}\new{c} P && \text{\tiny{(S-REST-COMM)}}\\
102102
\new{c}(P \comp Q)\ &\ \sequiv\ P \comp \new{c}Q\text{, if } c\not\in fi(P) && \text{\tiny{(S-REST-COMP)}}
103103
\end{align*}
104-
\emph{\caption{Structural equivalence axions in the synchronous \picalc}\label{spicalcaxioms}}
104+
\emph{\caption{Structural equivalence axioms in the synchronous \picalc}\label{spicalcaxioms}}
105105
\end{center}\end{insettable}
106106

107107
\section{Computation in the Synchronous \Picalc}
@@ -187,15 +187,14 @@ \section{Computation in the Synchronous \Picalc}
187187

188188
\section{Extended Example: Leader Elections}\label{secleaderelecs}
189189
Leader elections, a classic problem in distributed systems, are a good example of the power of the synchronous \picalc.
190-
Loosely, a leader election is a system where a group of processes, each with a unique identifier (via integers, perhaps), must agree on a `leader' process identification in a finite amount of time.
190+
A leader election is a system where a group of processes, each with a unique identifier (via integers, perhaps), must agree on a `leader' process identification in a finite amount of time.
191191
The processes vote on a process to be their leader by sending an integer-valued `vote' $v_i$ on a given output channel $o$.
192-
Ideally we want each of the processes to operate using the same `program', without any preference or priority hard-coded into that program.
192+
Ideally, we want each of the processes to operate using the same `program', without any preference or priority hard-coded into that program.
193193

194-
One means of identifying as `the same' the program run by the processes is by the concept of \defmargin{symmetry}.
195-
We say that two processes are symmetric if any they are equivalent under structural equivalence and a systematic renaming of their identifiers.
196-
To better understand what is meant by `a systematic renaming', assume that each process, channel name, and vote has a unique identifier $i \in \{1,..,n\}$.
197-
Now suppose we have an isomorphism $\sigma$ that maps these identifiers to other identifiers in the space $\{1,...,n\}$.
198-
we apply $\sigma$ to a term according to the following recursive definition:
194+
One means of specifying when two processes' programs are the same is by the concept of \defmargin{symmetry}.
195+
We say that two processes are symmetric if they are equivalent under structural equivalence and a systematic renaming of their identifiers.
196+
To better understand what is meant by `a systematic renaming', assume that each process $p_i$, channel name $c_i$, and vote $v_i$ has a unique identifier $i \in \{1,..,n\}$.
197+
Now suppose we have an isomorphism $\sigma$, given by following recursive definition, that maps these identifiers to other identifiers in the space $\{1,...,n\}$.
199198
\begin{insettable_wide}
200199
\begin{center}
201200
\begin{tabular}{r l l}
@@ -213,26 +212,28 @@ \section{Extended Example: Leader Elections}\label{secleaderelecs}
213212
\end{center}
214213
\emph{\caption{Rules for applying $\sigma$}\label{sigmarules}}
215214
\end{insettable_wide}
216-
Using these rules, we have a systematic function $\sigma$ for renaming identifiers in a process. Note that when a system of processes running in parallel are all symmetric to one another, we will say that the system is symmetric.
215+
Using these rules, we have a systematic function $\sigma$ for renaming identifiers in a process. When a system of processes running in parallel are all symmetric to one another, we will say that the system is symmetric.
217216
For example, consider the following symmetric system:
218217
\begin{align}
219218
P_0\comp P_1 \pdef \ssend{c_0}{} \send{o}{0} + \receive{c_1}{} \send{o}{1} \comp \ssend{c_1}{} \send{o}{1} + \receive{c_0}{} \send{o}{0}
220219
\label{leader_network_term}
221220
\end{align}
222-
Here is isomorphism $\sigma$ operates in the space $\{0,1\}$, mapping 1 to 0 and 0 to 1.
223-
Equivalently, it takes an identifier $i$ to $i+1 mod 2$.
224-
The output channel $o$ is a special case, and so we extend $\sigma$ to always map $o$ to itself.
221+
Here the isomorphism $\sigma$ operates in the space $\{0,1\}$, mapping 1 to 0 and 0 to 1.
222+
Equivalently, it takes an identifier $i$ to $(i+1)mod 2$.
223+
The output channel $o$ is special so we extend $\sigma$ to always map $o$ to itself.
225224
Hence $P_0 = \sigma(P_1)$ and we say that $P_0$ is symmetric to $P_1$.
226225

227-
Now that we have shown that (\ref{leader_network_term}) is a system of processes running `the same program', we need to show that it actually solves the leader election. This is not hard to show. There are two possibilities: either $P_0$ notifies $P_1$ on $c_0$ first, or $P_1$ notifies $P_0$ on $c_1$ first. Applying the reduction rule (R-SYNC) to (\ref{leader_network_term}), the first possibility gives
226+
Now that we have shown that (\ref{leader_network_term}) is a system of processes running `the same program', we need to show that it actually solves the leader election.
227+
There are two possibilities: either $P_0$ notifies $P_1$ on $c_0$ first, or $P_1$ notifies $P_0$ on $c_1$ first.
228+
Applying the reduction rule (R-SYNC) to (\ref{leader_network_term}), the first possibility gives
228229
\[
229230
\send{o}{0} \comp \send{o}{0}
230231
\]
231-
Here we see that both processes will agree in their output. Note that no substitutions were necessary since $\sends{c}{}$ is simply a\refmargin{handshake} handshake signal. Note also that these resulting processes are \emph{not} symmetric: applying the isomorphism $\sigma$ to $P_0$ no longer yields $P_1$.
232+
Here we see that both processes will agree in their output. Note that no substitutions were necessary since $\send{c}{}$ is simply a\refmargin{handshake} handshake signal. Note also that these resulting processes are \emph{not} symmetric: applying the isomorphism $\sigma$ to $P_0$ would yield $\send{o}{1}$.
232233

233234
If, on the other hand, $P_1$ notifies first, then again we apply (R-SYNC) to get
234235
\[
235236
\send{o}{1} \comp \send{o}{1}
236237
\]
237238
Again, a leader has been elected.
238-
Hence, we have given a term that successfully solves the leader election problem for symmetric processes in the special case of a two-process system. We will discuss more general leader elections in the next chapter.
239+
Hence, we have given a term that successfully solves the leader election problem for symmetric systems in the special case of a two processes. We will discuss more general leader elections in the next chapter.

0 commit comments

Comments
 (0)