23.08.2013 Views

Specification of Reactive Hardware/Software Systems - Electronic ...

Specification of Reactive Hardware/Software Systems - Electronic ...

Specification of Reactive Hardware/Software Systems - Electronic ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9.7 The Development <strong>of</strong> POOSL 297<br />

Empty<br />

Full(data)<br />

def<br />

def<br />

ch?in(data) Full(data)<br />

ch!out(data) Empty<br />

This specification can directly be translated into POOSL by representing states Empty<br />

and Full(data) by methods:<br />

process class Buf<br />

instance variables<br />

communication channels ch<br />

message interface ch?in(data) ch!out(data)<br />

initial method call Empty<br />

instance methods Empty ¡ data ¡ Full(data)<br />

ch?in(data);Full(data) ch!out(data);Empty<br />

To describe infinite, non-terminating behaviour, methods Empty and Full are defined<br />

by mutual recursion. But can methods really be defined this way without causing any<br />

problems? Unfortunately, the answer to this question is negative. Each time one method<br />

calls on another one, the depth <strong>of</strong> the process stack is increased by one. Since no method<br />

ever terminates, the stack will eventually grow beyond any bound. This problem has<br />

earlier been detected in [Blo93] in which context-free grammars are applied to specify<br />

the (infinite) behaviour <strong>of</strong> data communication protocols.<br />

There exists a solution to this problem though. Suppose the buffer is currently executing<br />

method Empty and is ready to execute method call Full(data). Since this method call<br />

is not followed by any other statement (the call is tail recursive) and since method<br />

Full as well as method Empty do not have any output parameters, the current local<br />

variable environment is never needed anymore. Upon invocation <strong>of</strong> method Full this<br />

environment can therefore be popped <strong>of</strong>f the process stack. Similarly, if the buffer calls<br />

on method Empty, the top <strong>of</strong> the stack can first be removed. In this way, the depth <strong>of</strong> the<br />

stack will never exceed 1.<br />

The general solution to the unbounded stack problem is formalised in terms <strong>of</strong> rule<br />

(g’) <strong>of</strong> the labeled-transition system <strong>of</strong> Subsection 9.5.3. It states that if a method with<br />

no output parameters is called from another method with no output parameters in a<br />

tail-recursive way, the top <strong>of</strong> the process stack can first be removed.<br />

9.7.5 Aborts and Interrupts<br />

The abort and the interrupt statements are used to specify that a process should be willing<br />

to accept some message at any instant.<br />

Without the explicit use <strong>of</strong> the abort operator or the interrupt operator, aborts and<br />

interrupts cannot be modelled naturally. Consider the following two statements:<br />

(ch1?n1; ch2?n2; ch3?n3) abort ch?n

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

Saved successfully!

Ooh no, something went wrong!