• No results found

A Theory for Refinement and Compatibility

2. ASYNCHRONOUS COMMUNICATION 59

... ... QBOB m m mB I={mB, . . .} nB n n QBOA O={n, . . .} IB={n, . . .} OB={m, . . .} OA={n, . . .} IA={m, . . .} A B I={nB, . . .} O={m, . . .}

FIGURE4.6. Transition systems with output queues each with one output queueQBOAandQ

B

OBdefined with respect to the output alphabet of

the respective PIO.

In general, there will be several output queues. The queues are encoded using PIOs. In order to synchronise such a system of transition systems and queues appropriately we need to apply a relabelling such that output messages are synchronised with the particular queue transition system. The outputs of a queue then replace the original outputs. A corresponding relabelling is indicated in Fig. 4.6. By this means, message exchange is buffered and PIOs do not synchronise directly anymore. Note that the indicated output relabelling is transparent for the communication partner.

LetL = ((I1, O1), . . . ,(In, On), T)be a partitioned IOL. Anasynchronous output

labellingwith respect toLis given byOB= (O1B, . . . , OkB)for someknwhereOiBis

defined bylB OiBiflOi, for all1 ≤ik. An asynchronous output labelling for a

PIOAis given by an asynchronous output labellingOBAwith respect toLA.

Definition 4.20(αPIO) APIO with asynchronous output labelling(αPIO for short) is a pair(A, OB)such thatAis a partitioned PIO andOBan asynchronous output labelling ofA. If|OB|=|OA|we simply writeAis aαPIO.

The relabelling ofAfor asynchronous communication with respect to OB is given by a

relabellingβfromLAtoL0Adefined by a functionf :

S

LA→SL0Asuch thatf(l) =lB

if lB ∈ OB, andf(l) = l else. Relabelling of a PIO for asynchronous communication

should not be applied more than once for the same set of labels. Therefore, labels given by an asynchronous output labelling must not yet exist in the set of labels of the underlying PIO. We require for anyαPIO(A, OB)thatS

LA∩SOB=∅.

Concerning the composability ofαPIOs we need to ensure that the asynchronous out-

put labels do not invalidate composability requirements of PIOs. Two αPIOs(A, OAB)

and (B, OBB)are composable ifA andB are composable and SL

A ∩SOBB = ∅ and

SL

B∩SOBA=∅.

2.1. FIFO Encoding and Buffered PIOs. We define an encoding of FIFO queues using PIOs which relies on the definition of output queues in the context of I/O-transition systems in Chap. 2. Since IOTSs are a formal representation of component implemen- tations (behaviours), this highlights that queues are indeed not supposed to be specified to allow for several different implementations of a queue. Instead we will use the same implementation-related formalism of FIFO queues on both levels, on the level of specifi- cations (PIOs) and on the level of implementations (IOTSs).

Definition 4.21(FIFO Encoding) ThePIO encoding of a FIFO queue with respect to a set M, writtenQBM, is given byQBM = (L, S, s0,,Π), where(L, S, s0,∆)is a queue IOTS overMandΠ = ∆.

An asynchronous output labelling specifies which messages of the given transition system should be exchanged using FIFO buffers. With Def. 4.21 it is straightforward to define a corresponding notion of buffered PIOs.

60 4. A THEORY FOR REFINEMENT AND COMPATIBILITY

Definition 4.22(Buffered PIO) Thebuffered PIOfor anαPIO(A,(O1, . . . , Ok))for some

k≤ |OA|is defined by

Ω(A,(O1, . . . , Ok)) = (QBO1⊗ · · · ⊗Q

B Ok),

whereβ is a relabelling ofAfor asynchronous communication w.r.t.(O1, . . . , Ok). It is

called completely buffered, written Ω(A), ifk = |OA|. We abbreviate the product of

output queuesQBO1⊗ · · · ⊗QBOkbyQBA.

Next we ensure that buffered PIOs can be used just like ordinary PIOs. In particular, their composition is associative and commutative using the product operator for PIOs. Also note thatΩ(A,) =A.

Lemma 4.23 Let(A, OBA)and(B, OBB)beαPIOs. Then the following holds: (1) Ω(A, OBA)is a PIO withLΩ(A,OB

A)= (IA, OA, TA

S

OBA).

(2) If (A, OBA) and (B, OBB) are composable thenΩ(A, OAB) and Ω(B, OBB) are composable.

PROOF. (1) The output queues for(A, OAB)are composable, sinceOABis a partition

and, by definition, queue inputs are disjoint from queue outputs and the sets of internal labels are empty. ThusQBA is defined. LetΩ(A, OAB) = (QBA); andQBA are

composable since (A, OBA)is anαPIO, that is, is a valid PIO andIAβIQB

A = ∅, OAβOQB A =∅,TAβ∩ S QBsA=∅andTQB A∩ S

=∅by definition. HenceΩ(A, OAB)is

a PIO. Now, by definition of IOL products,IΩ(A,OB

A)= (IAβ∪ S IQB A)\S(Aβ, Q B A) =IA, OΩ(A,OB A)= (OAβ∪ S OQB A)\S(Aβ, Q B A) =OQB

A =OAandTΩ(A,OBA)=TAβ

S

TQB

A

S(Aβ, QBA) =TA∪SOAB.

(2) Using (1) we need to proof that IAIB = ∅,OAOB =∅,(TA∪SOBA)∩

S

OBB =∅and(TB∪SOBB)∩

S

OAB =∅, which is a consequence of composability of (A, OBA)and(B, OBB). Moreover, sinceIΩ(A,OB

A) =IAandOΩ(A,OBA) = OA, we have

that shared labels will still be uniquely assigned to elements of the partitions and hence also the requirement for the composability w.r.t partitions is preserved.

Example 4.24(Buffered PIO) Buffered PIOs are used to model buffered communication between processes modelled by finite-state control automata, in our case by PIOs. With the buffered producer example in Ex. 4.2 we considered a producer PIO composed with an output buffer, which encodes its capacity explicitely by a corresponding number of input transitionsput, followed by an output transitionget. Instead of this explicit modelling of the buffer’s capacity, we could use buffered PIOs to abstract from capacity issues and focus solely on the control part, which is in particular useful for the modelling of a distributed system. In this case, the buffer between producer and consumer not only models storage but is also used to decouple and control the message exchange.

For instance, the usual modelling of a producer/consumer-architecture requires the consumer to wait with getting items from the storage as long as there are no items avail- able, i.e. as long as the buffer is empty. Such a requirement could be modelled with a buffer processBufCtras depicted in Fig. 4.7.

(a)Prod /put p0 (b)BufCtr put/ /get b1 b0