• No results found

Schizophrenic Statements

3.2 Semantic Problems

3.2.1 Schizophrenic Statements

Schizophrenic statements are statements that have several active instances at the same macro step. This may happen only if the statement is contained in a loop, since it is required to restart the statement at termination or abortion time. If the statement is contained in n nested loops, it may even be the case that n instances exist at the same point of time, for example, if all of the loops are restarted and aborted at the same point of time.

As variables have a uniquely determined value for each macro step, it is seems not to be problematic if one and the same statement is started several times in the same macro step. However, the scopes of the local variables are entered and left in micro steps of the execution, so that the different instances of the schizophrenic statement may have to consider different scopes of local variables. This leads to the notion of so called reincarnations of local variables.

module Schizophrenic(event &x0,&x1,&x2,&x3) { loop {

event x;

if(x) emit x1; else emit x0; assert(!x);

pause; emit x;

if(x) emit x3; else emit x2; assert(x);

} }

Fig. 3.1. Schizophrenic local declaration

As an example, consider the module given in Figure3.1. This module has only one control flow location which is the pause statement in its loop body. If the execution proceeds from that location, it emits the local variable x, so that the following conditional statement emits x3. Clearly, the assertion assert(x) holds. However, as the loop body terminates, also the scope of the local declaration is left, and the loop body is restarted due to a new loop iteration. For this reason, a new scope of the local declaration statement is opened, and a new incarnation of the local variable x is generated. Hence, there are now two instances of the local variable x: one living in the scope

of the previous loop body, and another one living in the scope of the new loop body. While the older incarnation is true, the new one is false, so that the incarnations have different values. Hence, also the assertion assert(!x) holds, which is not a contradiction, since the two assertions refer to different incarnations of x.

A program with multiple schizophrenic instances is shown in Figure3.2. When started, the control flow occupies the three locations ell0, ell1, ell2, and ell3 and no signals are emitted except for y000. At the next point of time, a lot of micro steps are executed:

• The local variables x1, x2, and x3 are emitted by the three threads that start from locations ell1, ell2, and ell3, respectively. The innermost loop iterates and executes the switch statement that therefore emits y111. This thread aims at stopping at location ell0, but is aborted as will be ex- plained next.

• Since x3 holds, the weak abort statement with abortion condition x3

aborts its body statement. As this weak abort statement is contained in a loop, the loop body is restarted, so that a new scope of x3 is generated. This thread then stops at locations ell3 and ell0 after having again exe- cuted the switch statement that emits this time y110.

• Concurrently, the weak abort statement with abortion condition x2 aborts its body statement, and the surrounding loop body is restarted, so that new scopes of x2 and x3 are generated. This thread then stops at loca- tions ell2, ell3 and ell0 after having once more executed the switch statement that emits this time y100.

• Finally, the weak abort statement with abortion condition x1 also aborts its body statement, and the surrounding loop body is restarted, so that further new scopes of x1, x2 and x3 are generated. This thread then stops at locations ell1, ell2, ell3 and ell0 after having once more executed the switch statement that emits this time y000.

Hence, after the starting point of time, the signals y000, y100, y110, and y111 are emitted, while the other outputs are never emitted. The local variables x3, x2, and x1 have three, two and one incarnations that concurrently exists with the incarnation of the old scope.

Schizophrenic statements are not a big problem. The semantics and the compilation techniques that are described in the following chapters all cope with this issue. In particular, schizophrenia problems can be easily solved by generating copies of internal data structures that are used for compilation like hardware gates or nodes in a data flow graph. Moreover, the blow-up that occurs due to these necessary copies is polynomial: We will see in the later chapters that a quadratic blow-up suffices. This quadratic blow-up is obtained only with extreme examples like the one of Figure3.2, and does seldom occur in practice.

Hence, schizophrenia problems are neither a problem for state-of-the-art compilers nor for the definition of the language’s semantics. However, pro-

module Gonthier02(event &y111,&y110,&y101,&y100, &y011,&y010,&y001,&y000) { loop { event x1; weak abort { ell1:pause; emit x1; } || loop { event x2; weak abort { ell2:pause; emit x2; } || loop { event x3; weak abort { ell3:pause; emit x3; } || loop { switch

(!x1 & !x2 & !x3) do emit y000; (!x1 & !x2 & x3) do emit y001; (!x1 & x2 & !x3) do emit y010; (!x1 & x2 & x3) do emit y011; ( x1 & !x2 & !x3) do emit y100; ( x1 & !x2 & x3) do emit y101; ( x1 & x2 & !x3) do emit y110; ( x1 & x2 & x3) do emit y111; else nothing; ell0:pause; } when(x3); } when(x2); } when(x1); } }

grammers must be aware of schizophrenia problems that might sometimes be confusing.