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.
160 CHAPTER 7. MODELLING MUTUAL EXCLUSION ALGORITHMS<br />
we shall assume, for the sake of simplicity, that processes cannot fail or terminate<br />
within the critical section. Under these assumptions, the initial behaviour of<br />
process P1 can be described by the following CCS expression:<br />
P1<br />
def<br />
= b1wt.kw2.P11 .<br />
The above expression says that process P1 begins by writing true in variable b1 <strong>and</strong><br />
2 in variable k. Having done so, it will enter a new state that will be represented<br />
by the constant P11. This new constant will intuitively describe the behaviour of<br />
process P1 while it is executing the following line of pseudocode:<br />
while (bj <strong>and</strong> k = j) do skip.<br />
To simulate this ‘busy waiting’ behaviour, we expect that process P11 will<br />
• read the value of the variables bj <strong>and</strong> k,<br />
• loop back to P11 if bj is true <strong>and</strong> k is equal to 2, <strong>and</strong><br />
• move to a new state, say P12, otherwise. In state P12, we expect that process<br />
P1 will enter <strong>and</strong> then exit the critical section.<br />
The first thing to note here is that we n<strong>ee</strong>d to make a decision as to the precise<br />
semantics of the informal pseudocode expression<br />
bj <strong>and</strong> k = j.<br />
How is this boolean conjunction evaluated? Is it evaluated from left to right, or<br />
from right to left? Assuming that it is evaluated from left to right, is the second<br />
conjunct evaluated if the first turns out to yield false? Different answers to these<br />
questions will produce different CCS processes. In what follows, we shall present<br />
a CCS description for process P11 under the assumption that conjunctions are evaluated<br />
from left to right, <strong>and</strong> that the second conjunct is not evaluated if the value<br />
of the first is equal to false. Under these assumptions, we can write<br />
P11<br />
def<br />
= b2rf.P12 + b2rt.(kr2.P11 + kr1.P12) .<br />
Exercise 7.2 Would it have b<strong>ee</strong>n a good idea to define P11 thus:<br />
P11<br />
def<br />
= b2rf.P12 + b2rt.kr2.P11 + b2rt.kr1.P12 ?<br />
Argue for your answer.