Design and Implementation of TinyGALS: A Programming Model for ...
Design and Implementation of TinyGALS: A Programming Model for ...
Design and Implementation of TinyGALS: A Programming Model for ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Application def.<br />
include modules{<br />
A;<br />
B;<br />
};<br />
globals{<br />
statevar;<br />
};<br />
statevar A_param<br />
statevar B_param<br />
...<br />
// Module def. <strong>for</strong> A<br />
include components{<br />
A1;<br />
};<br />
parameters{<br />
int A_param;<br />
};<br />
...<br />
Figure 11: Defining <strong>and</strong> accessing TinyGUYS variables.<br />
// Component impl. <strong>for</strong> A1<br />
...<br />
void fire() {<br />
...<br />
int a;<br />
a=PARAMETER_GET(A_param);<br />
a++;<br />
PARAMETER_PUT(A_param)(a);<br />
...<br />
};<br />
variable. TinyGUYS variables are updated atomically by the scheduler only when it is safe<br />
(e.g., after one module finishes <strong>and</strong> be<strong>for</strong>e the scheduler triggers the next module). One<br />
can think <strong>of</strong> this as a way <strong>of</strong> <strong>for</strong>malizing race conditions. We discuss how to eliminate race<br />
conditions in Section 3.1.<br />
TinyGUYS have global names (GLOBALSA) that are mapped to the parameters (PARAMET ERSM)<br />
<strong>of</strong> each module M. If a component C uses a parameter, it must declare it as an external<br />
variable (XC). Figure 11 shows some sample code <strong>for</strong> defining <strong>and</strong> accessing TinyGUYS<br />
variables. The left-h<strong>and</strong> column <strong>of</strong> Figure 11 shows an application definition, which con-<br />
tains a list <strong>of</strong> global variable names, as well as a list <strong>of</strong> mappings from global names to local<br />
names. These local variables must be defined as parameters <strong>of</strong> the modules; this is shown<br />
in the center column <strong>of</strong> Figure 11. Local variables can be accessed within a component<br />
by using special constructs, PARAMETER_GET <strong>and</strong> PARAMETER_PUT, as shown in the<br />
right-h<strong>and</strong> column <strong>of</strong> Figure 11. This style <strong>of</strong> declaration, in which the types <strong>of</strong> the global<br />
variables must be declared at the module level, is slightly awkward. This means that the<br />
types must be declared <strong>for</strong> each module that uses the global variables. It also increases the<br />
fragility <strong>of</strong> the component code, since the components do not know the types <strong>of</strong> the global<br />
variables. In the future, we plan to improve this mechanism to use scoping, perhaps in a<br />
way similar to scoped parameters in Ptolemy II [11]. We could also use the Ptolemy II type<br />
system to improve the way in which types must be declared in <strong>TinyGALS</strong>.<br />
22