14.08.2013 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

158 CHAPTER 7. MODELLING MUTUAL EXCLUSION ALGORITHMS<br />

initial value of the variable k can be arbitrary. In order to ensure mutual exclusion,<br />

each process Pi (i ∈ {1, 2}) executes the following algorithm, where we use j to<br />

denote the index of the other process.<br />

while true do<br />

begin<br />

‘noncritical section’;<br />

bi := true;<br />

k := j;<br />

while (bj <strong>and</strong> k = j) do skip;<br />

‘critical section’;<br />

bi := false;<br />

end<br />

As many concurrent algorithms in the literature, Peterson’s mutual exclusion algorithm<br />

is presented in pseudocode. Therefore one of our tasks, when modelling the<br />

above algorithm, is to translate the pseudocode description of the behaviour of the<br />

processes P1 <strong>and</strong> P2 into the model of labelled transition systems or into Milner’s<br />

CCS. Moreover, the algorithm uses variables that are manipulated by the processes<br />

P1 <strong>and</strong> P2. Variables are not part of CCS because, as discussed in Section 1.2,<br />

process calculi like CCS are based on the message passing paradigm, <strong>and</strong> not on<br />

shared variables. However, this is not a major problem. In fact, following the<br />

message passing paradigm, we can view variables as processes that are willing to<br />

communicate with other computing agents in their environment that n<strong>ee</strong>d to read<br />

<strong>and</strong>/or write them.<br />

By way of example, let us consider how to represent the boolean variable b1 as<br />

a process. This variable will be encoded as a process with two states, namely B1t<br />

an B1f. The former state will describe the ‘behaviour’ of the variable b1 holding<br />

the value true, <strong>and</strong> the latter the ‘behaviour’ of the variable b1 holding the value<br />

false. No matter what its value is, the variable b1 can be read (yielding information<br />

on its value to the reading process) or written (possibly changing the value held<br />

by the variable). We n<strong>ee</strong>d to describe these possibilities in CCS. To this end, we<br />

shall assume that processes read <strong>and</strong> write variables by communicating with them<br />

using suitable communication ports. For instance, a process wishing to read the<br />

value true from variable b1 will try to synchronize with the process representing<br />

that variable on a specific communication channel, say b1rt—the acronym means<br />

‘read the value true from b1’. Similarly, a process wishing to write the value false<br />

into variable b1 will try to synchronize with the process representing that variable<br />

on the communication channel b1wf—‘write false into b1’.<br />

Using these ideas, the behaviour of the process describing the variable b1 can<br />

be represented by the following CCS expressions:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!