Reactive Systems: Modelling, Specification and Verification - Cs.ioc.ee
Reactive Systems: Modelling, Specification and Verification - Cs.ioc.ee
Reactive Systems: Modelling, Specification and Verification - Cs.ioc.ee
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
CHAPTER 7. MODELLING MUTUAL EXCLUSION ALGORITHMS 161<br />
To complete the description of the behaviour of the process P1 we are left to present<br />
the defining equation for the constant P12, describing the access to, <strong>and</strong> exit from,<br />
the critical section, <strong>and</strong> the setting of the variable b1 to false:<br />
P12<br />
def<br />
= enter1.exit1.b1wf.P1 .<br />
In the above CCS expression, we have labelled the enter <strong>and</strong> exit actions in a way<br />
that makes it clear that it is process P1 that is entering <strong>and</strong> exiting the critical<br />
section.<br />
The CCS process describing the behaviour of process P2 in Peterson’s algorithm<br />
is entirely symmetric to the one we have just provided, <strong>and</strong> is defined thus:<br />
P2<br />
P21<br />
P22<br />
def<br />
= b2wt.kw1.P21<br />
def<br />
= b1rf.P22 + b1rt.(kr1.P21 + kr2.P22)<br />
def<br />
= enter2.exit2.b2wf.P2 .<br />
The CCS process term representing the whole of Peterson’s algorithm consists<br />
of the parallel composition of the terms describing the two processes running the<br />
algorithm, <strong>and</strong> of those describing the variables. Since we are only interested in the<br />
behaviour of the algorithm pertaining to the access to, <strong>and</strong> exit from, their critical<br />
sections, we shall restrict all of the communication channels that are used to read<br />
from, <strong>and</strong> write to, the variables. We shall use L to st<strong>and</strong> for that set of channel<br />
names. Assuming that the initial value of the variable k is 1, our CCS description<br />
of Peterson’s algorithm is therefore given by the term<br />
Peterson def<br />
= (P1 | P2 | B1f | B2f | K1) \ L .<br />
Exercise 7.3 (M<strong>and</strong>atory!) Give a CCS process that describes the behaviour of<br />
Hyman’s ‘mutual exclusion’ algorithm. Hyman’s algorithm was proposed in the<br />
reference (Hyman, 1966). It uses the same variables as Peterson’s.<br />
In Hyman’s algorithm, each process Pi (i ∈ {1, 2}) executes the algorithm in<br />
Figure 7.1, where as above we use j to denote the index of the other process. <br />
Now that we have a formal description of Peterson’s algorithm, we can set ourselves<br />
the goal to analyze its behaviour—manually or with the assistance of a software<br />
tool that can h<strong>and</strong>le specifications of reactive systems given in the language<br />
CCS. In order to do so, however, we first n<strong>ee</strong>d to specify precisely what it means for<br />
an algorithm to ‘ensure mutual exclusion’. In our formalization, it s<strong>ee</strong>ms natural<br />
to identify ‘ensuring mutual exclusion’ with the following requirement:<br />
At no point in the execution of the algorithm will both processes P1<br />
<strong>and</strong> P2 be in their critical sections at the same time.