Subject: Re: SDL-News: Import/Export - reg
From: Rick Reed TSE (rickreed#tseng.co.uk)
Date: Wed Jun 13 2001 - 13:37:43 GMT
Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----
The reply given by John Svensson is essentially correct but is rather
lacking in explanation, and the SDL is still incorrect.
I assume that what was intended is that p1 receives a signal setx (from the
environment), keeps the received value and exports this value for use by
other processes. I assume that process p2 should import the exported value
and (for the purposes of the example) then sends the value in the signal
The SDL PR given by John Svensson is incorrect because:
1. "Package referenced;" is unnecessary and incorrect SDL.
2. The signal setx is in the wrong direction on SIGNALROUTE SR1. This
definition should be:
SIGNAL SR2 FROM ENV TO p1 WITH setx
however, the signal route names are never used and therefore can be omitted:
SIGNALROUTE FROM p2 TO ENV WITH setx;
SIGNALROUTE FROM ENV TO p1 WITH setx;
should be removed from p1, because it is not needed (I guess it was inserted
because of the direction error).
The purpose of the REMOTE X Integer; definition in the block is to
implicitly define the signal communication for the IMPORT operation. The
routing of the communication can (optionally) be shown on communication
paths between the processes as REMOTE X in a signal list.
In the original example EXPORT(x) was used just before OUPUT fromp2(x), so I
assume the intention was to import the value of x to be used in the OUTPUT.
IMPORT(x) is the correct construction for this (rather than EXPORT), but it
is an expression rather than an action, so two changes have to be made:
a) Change EXPORT to IMPORT;
b) Move the IMPORT to a place where an expression is allowed - in this case
to replace x as the parameter.
What IMPORT does is send an implicit signal to a process that exports the
remote variable (in this case p1 - the only such process), and waits for an
implicit response signal. If there is more than one process instance that
exports using the remote variable, either the signal is sent to an arbitrary
process instance or the routing of the implicit signal to the exporter can
constrained (by communication paths and/or by specifying the destination in
the IMPORT) to one or more specific instances. This is similar to ensuring
that an OUTPUT goes to the correct process instance.
The EXPORT action is needed in the exporter, because the exporting process
has control over the value which is exported: the importer gets the last
value exported, which is not necessarily the same as the current value of
the exported variable. What happens is that when EXPORT is interpreted, the
value is copied to a hidden variable and it is this variable that is used
when the IMPORT is serviced. Note that because IMPORT is implemented by
signals, the exporter replies to the importer when it is in a state (and
returns to the same state).
The "IMPORTED x Integer;" definition is not needed (in SDL-96 or SDL-2000),
and could be confusing, because this does not define a local variable called
x. To minimise the number of times that the IMPORT operation is used, it is
best to copy the value into a local variable (which could have the same
name) for example:
DCL x Integer;
x:=IMPORT(x); /* the first "x" is the local variable,
the second "x" is a remote variable */
The following is correct according to Cinderella:
FROM p2 TO ENV WITH fromp2;
PROCESS p2 REFERENCED;
PROCESS p1 REFERENCED;
FROM ENV TO p1 WITH setx;
REMOTE x integer;
IMPORTED x integer;
DCL EXPORTED x integer;
-- Rick Reed - rickreed#tseng.co.uk Tel:+44 1455 55 96 55 Fax:+44 1455 55 96 58 Mob.:+44 7970 50 96 50
john.svensson#telelogic.se at john.svensson#telelogic.se wrote on 12/06/2001 21:01:
> Dear sir, > > It is necessary to change a few things in your system to make the import of > a variable work. > > There must be a remote declaration to set the scope for the variable. > You must make an import operation in the importing process. > There must be an export statement in the exporting process. > > package referenced; Error - no package name > > package mypackage; > signal setx(integer),fromp2(integer); > endpackage; > > use mypackage; > block myblock; > remote x integer; > signalroute SR1 from p2 to env with fromp2; > signalroute SR2 from p1 to env with setx; > process p1 referenced; > process p2 referenced; > endblock; > > process <<block myblock>>p2; > imported x integer; Not needed SDL-96 or later. > start; > nextstate waitx; > > state waitx; > input none; > > output fromp2(import(x)); > nextstate -; > endstate waitx; > endprocess; > > process<<block myblock>>p1; > signalset setx; Not needed. > dcl exported x integer; > > start; > nextstate init; > > state init; > input setx(x); Error - no sender. > export(x); > nextstate-; > endstate init; > endprocess; > > *** END ***
Elangovan Angannan at sdlelango#yahoo.com wrote on 12/06/2001 13:48:
> Become an SDL Forum Society member > <http://www.sdl-forum.org/Society/members.htm> > The originator of this message is responsible for its content. > -----From Elangovan Angannan <sdlelango#yahoo.com> to sdlnews ----- > > Dear SDL experts, > > I am new to SDL. Could you please help in clarifying > my doubt regarding exporting variables? > > I have developed a system with a block "myblock" > containing two processes "p1" and "p2". p1 contains an > exported variable. But I was not able to import the > variable from p2. I have given the system in SDL/PR > notation below: > > *** START *** > > package referenced; > > package mypackage; > signal setx(integer),fromp2(integer); > endpackage; > > use mypackage; > block myblock; > signalroute SR1 from p2 to env with fromp2; > signalroute SR2 from p1 to env with setx; > process p1 referenced; > process p2 referenced; > endblock; > > process <<block myblock>>p2; > imported x integer; > > start; > nextstate waitx; > > state waitx; > input none; > export(x); > output fromp2(x); > nextstate -; > endstate waitx; > endprocess; > > process<<block myblock>>p1; > signalset setx; > dcl exported x integer; > > start; > nextstate init; > > state init; > input setx(x); > nextstate-; > endstate init; > endprocess;
--End text from Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews --- For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>
This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT