You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
614
614
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.
616
616
617
617
Let's use action semantics to make sure locking behaves as expected.
618
618
We first note using (A-REP) that the above can internally evolve over $\tau$ to
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.
658
658
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.
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.
191
191
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.
193
193
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\}$.
\emph{\caption{Rules for applying $\sigma$}\label{sigmarules}}
215
214
\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.
217
216
For example, consider the following symmetric system:
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+1mod 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.
225
224
Hence $P_0 = \sigma(P_1)$ and we say that $P_0$ is symmetric to $P_1$.
226
225
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
228
229
\[
229
230
\send{o}{0} \comp\send{o}{0}
230
231
\]
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}$.
232
233
233
234
If, on the other hand, $P_1$ notifies first, then again we apply (R-SYNC) to get
234
235
\[
235
236
\send{o}{1} \comp\send{o}{1}
236
237
\]
237
238
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