• No results found

one sender and one receiver in this system, both processes will eventually terminate. Note that for executing receive, Proc2has to wait until Proc1has send a value to the initially empty channel c. The exact semantics of the communication operations send and receive are given by:

l: send(c, e) ≡ l : hawait ¬fullc; bufferc[rearc] := e;

emptyc:=false;

rearc:=rearc+ 1mod n;

fullc:= (rearc+ 1mod n = frontc)i and respectively,

l: receive(c, x) ≡ l : hawait ¬emptyc; x:=bufferc[frontc];

fullc:=false;

frontc:=frontc+ 1mod n;

emptyc:= (rearc=frontc+ 1mod n)i

where c is a communication channel of length n, e is an expression of the same type as c and x is a variable, again of the same type as c. Hence, values transferred via channels have to be compatible with the channels type.

With message passing we have another form of inter-process communica-tion that we want to consider in our approach to the verificacommunica-tion of concurrent systems. Indeed, message passing is a concept of high practical relevance, especially in the field of distributed computing where no shared memory exists. Moreover, the introduction of communication channels involves several new issues with regard to the correctness of concurrent systems. For exam-ple, a processes might “starve” in front of a receive operation, because no communication partner is available. This and similar process synchronisation problems are in the focus of our verification technique.

3.2 Parameterised Systems

In the previous sections of this chapter we have introduced our notion of concurrent systems Sys = kni=1Proci. In our examples we solely considered sys-tems with a fixed number n of processes. However, in practice, many syssys-tems are paramterised with regard to the number of processes: Network protocols for mutual exclusion, cache coherence or leader election are commonly de-fined for an arbitrary number of processes running in parallel. Verifying such

parameterised systems is particularly hard and even undecidable in the gen-eral case [7]. Nevertheless, these systems are in the focus of our verification technique, too. In this section we give a fundamental introduction to the field of parameterised systems. We start with a simple example:

y:semaphore where y = 1

The system Sys4in Figure 3.4 consists of N processes competing for access to a critical section. In the parametrised setting we assume that the capital N does not represent a fixed integer but a parameter, and thus, an unbounded number of processes might run in parallel. As we can see, Sys4is iteratively defined over the process index i, and each process Prociexecutes the same sequence of operations. The processes only differ in their unique index value. Therefore we say that Sys4is fully symmetric with respect to process indices. Symmetry in paramterised systems is a characteristic that can be efficiently exploited for verification. Moreover, several real-life examples of parameterised systems are inherently symmetric, since their processes are commonly instances of one and the same process template. Hence, we also want to look at such fully symmetric systems in our approach to verification. In general, a fully symmetric system is defined as follows:

Definition 3.3 (Fully Symmetric System).

Let Proc be a process defined over Vars∪ Varl where Vars is a set of shared variables and Varl is a set of local variables. Then the corresponding fully symmetric system is defined as

Sys= ki∈PIDNProciover Var = Vars∪ (Varl× PIDN)

where N ∈ N is a parameter of Sys and PIDN is a set of process indices of size N. Moreover, each Proci is a replication of Proc defined over Vari= Vars∪ (Varl× i), i.e. Proci is obtained from Proc by preserving the control structure of Proc, and by replacing each basic operation bop in Proc by bopi= bop[x/(x, i) | x ∈ Varl].

Hence, all processes in Sys execute the same code and there exists a replication of the set of local variables Varl for each process, i.e. the process indices are lifted to Varl. Again, this fits into our general notion of concurrent systems, since we can rewrite Varl× PIDNasSi∈PID

NVari. Moreover, our understanding

3.2 Parameterised Systems 39 of symmetry demands that each process has the same initial condition, i.e.

that all replications of a variable from Varl have the same initial value.

In the example system Sys4we have one shared semaphore variable y and no (explicit) local variables. However, each process in Sys4has a program counter ranging over identical locations, and thus, in a broader notion we can regard the program counter pc as a local variable with N replications:

pc× PIDN.

Full symmetry is a strong restriction on a parameterised system, because it demands that that all processes are identical. In fact, only few real-life systems fulfill this requirement. Nevertheless, in much more cases the processes of a parameterised system can at least be divided into classes of fully symmetric processes. We call such a system class-wise symmetric. A simple example is given below in Figure 3.5.

Fig. 3.5 Class-wise symmetric system Sys5= ki∈PIDRd

NRd Rdikj∈PIDWrt

NWrt Wrtj consisting of a reader class Rd and a writer class Wrt. PIDRdN

Rd and PIDWrtN

Wrtare sets of process indices with parameterised sizes NRd∈ N resp. NWrt∈ N.

The system Sys5 implements an algorithm for the readers-writers problem [45]. We have two classes of processes: readers Rdiand writers W rtj. Multiple readers may enter the critical section at the same time, whereas if one writer is modifying data, no other process is allowed to access the critical section. The problem is solved via a semaphore with a capacity of NRd, which is actually the (parameterised) number of reader processes in the system. As we have two classes, the overall set of process indices PIDN is partitioned into PIDRdN

Rd

(readers) and PIDW rtN

W rt(writers). More generally, a class-wise symmetric system consisting of k classes is defined as follows:

Definition 3.4 (Class-Wise Symmetric System).

Let {Proc1, . . . , Prock} be a set of processes where each Procm(1 ≤ m ≤ k) is defined over a set of variables Varm= Varsm∪Varml with Varl1, . . . ,Varkl pairwise disjoint. We call the index m the class of a process Procm. Then, according to Definition 3.3, we obtain a corresponding fully symmetric system Sysm for each class m:

Sysm= ki∈PIDm

NmProcmi over Varm= Varms ∪ (Varml × PIDmNm)

We assume that the sets PID1N

1, . . . , PIDkN

kare pairwise disjoint, and thus, every process Procmi has a unique index. In addition, we assume that each class m has a dedicated program counter pcmwith a replication for each process in the class: pcm× PIDmN

m. Now, the corresponding class-wise symmetric system is defined as

Sys= kkm=1Sysmover Var =

k [

m=1

Varms ∪ (Varml × PIDmNm) .

We explicitly allow that the variable sets Var1s, . . . ,Varskhave common elements, i.e. communication between processes of different classes is permitted.

So far, we have seen that there exists a wide range of different kinds of concurrent systems in practical use. The systems can be distinguished by the underlying concept of communication, by symmetry characteristics, and whether they are finite or not. Nevertheless, we have introduced a general notion of concurrent systems, under which all these different kinds are com-prised. In the next section we will show how our systems can be transferred into a computational model for verification.