Subject: Re: SDL-News: Question: Algorithms
From: Rick Reed TSE (rickreed#tseng.co.uk)
Date: Sun Mar 19 2000 - 12:57:48 GMT
The originator of this message is responsible for its content.
-----From Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----
On 19/03/2000 02:23 Soumitri Soumya Pal<spal#ics.uci.edu> wrote:
> When a process receives a signal, it has to update a priority queue and a
> normal queue looking at the parameters of the signal. Definitely there is an
> algorithm for doing this. How do you represent an algorithm in SDL? I think
> representing an algorithm graphically like a flow chart will be cumbersome
> compared to representing it textually. Can you give a reference to the
> algorithm which is written in C/C++?
As you indicate, it is certainly possible to represent algorithms in SDL/GR
as a drawing. I will not enter into the pros and cons representation here,
because this would be a long discussion without definitive conclusions.
However, your first request is how to represent algorithms textually.
Until SDL-2000, the options were:
a) to use SDL/PR for the algorithmic part of the model;
b) to use an EXTERNAL procedure or external operator, defined in some some
language other than SDL;
c) to use the ALTERNATIVE ... ENDALTERNATIVE construct to provide operator
body definitions in a language other than SDL, embedded in the SDL.
In SDL-2000 there are specific constructs to support textual algorithms
within SDL/GR.
Tools have also provided non-standardised ways for using algorithms in other
languages with SDL.
1. Using SDL/PR for algorithms
Both SDL/GR and SDL/PR can contain referenced definitions not directly
contained in the SDL. In SDL/GR this is the normal way in including items:
for example, graphical block reference to a block definition, graphical
process reference to a process definition and (in particular) graphical
procedure reference to a procedure definition. In SDL/PR, it is more usual
to include the item directly, but references are also allowed: for example
BLOCK b REFERENCED;
Whenever a reference is used, the referenced item can be either an SDL/GR
diagram or an SDL/PR definition. A graphical procedure reference can
therefore refer to either a procedure diagram (graphical) or a procedure
definition (textual). The procedure definition can then be given in SDL/PR.
In the case, of operator definitions these are defined as part of a data
type definitions, which only have a textual form and therefore an operator
definition that is not referenced must be given graphically. Simple operator
definitions can therefore be written in a text box as part of a data type
definition. For example,
NEWTYPE Int20 INHERITS Integer OPERATORS ALL
ADDING
OPERATORS inc: Int20-> Int20;
OPERATOR inc; FPAR i20 Int20; RETURNS Int20;
START;
RETURN IF (i20 = 20 ) THEN 0 ELSE i20+1 FI;
ENDOPERATOR inc;
DEFAULT 0; CONSTANTS 0:20
ENDNEWTYPE Int20;
It is also possible to introduce a dummy data type that has no other purpose
than to introduce one (or more) operators. For example,
NEWTYPE powerint
OPERATORS powerint: Integer, Integer -> Integer;
OPERATOR powerint; FPAR i, power Integer; RETURNS Integer;
START;
RETURN IF (power<0) THEN 0 ELSE
IF power=0 THEN 1 ELSE i * powerint(i, power-1) FI
FI ;
ENDOPERATOR powerint;
ENDNEWTYPE powerint;
However, some disadvantages are that SDL/PR is rather verbose, does not have
specific support for loops, and only has generic DECISION case statements
(rather than IF THEN ELSE statement). The SDL-2000 textual algorithm syntax
is more compact and has direct support for loops and IF statements. The
SDL-2000 textual algorithm syntax can also be used in task boxes and for
textual procedure definitions in text boxes.
The SDT tool already supports textual algorithms.
2. EXTERNAL procedures and operators
In this case the body of the procedure or operator is not given in SDL at
all. Instead the body is given as a reference. For example,
PROCEDURE divideq;
FPAR
IN/OUT QueueType,
IN/OUT QueueType;
RETURNS Boolean;
EXTERNAL
This is given as the textual definition of the procedure. How this is linked
with the actual procedure is tool specific. It can be linked to any
language.
3. ALTERNATIVE data
SDL also allows the form
NEWTYPE Int20 INHERITS Integer OPERATORS ALL
ADDING
OPERATORS inc: Int20-> Int20;
ALTERNATIVE text_name /*such as C++*/
any text except
ENDALTERNATIVE;
DEFAULT 0; CONSTANTS 0:20
ENDNEWTYPE Int20;
How this is mapped to SDL is left open, and (as far as I am aware) this is
not implemented by any tools, but can (in theory) be linked to any language.
-- Rick Reed - rickreed#tseng.co.uk Tel:+44 1455 55 96 55 Fax:+44 1455 55 96 58 Mob.:+44 7970 50 96 50-----End text from Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----
This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT