IBM
Contents Index Previous Next



How to Obtain PId Literals


This section describes a way to obtain PId literals for static process instances. PId literals will make it possible to simplify the start-up phase of an SDL system, as direct communication (OUTPUT TO) may be used from the very beginning. It is otherwise necessary to start sending signals without TO, as the only PId values known at the beginning are the Parent - Offspring relations.

Note:

This ADT cannot be used in OS integrations or with Cmicro. There are, however, a special version for OS integrations that can be found in the directory for the OS integration, and a special version for Cmicro that can be found in the Cmicro installation directory.

Note:

PId literals cannot be created for processes within block types or system types.

Purpose

In SDL the only way to obtain a PId value is to use one of the basic functions Self, Parent, Offspring, or Sender. Such values may then, of course, be passed as parameters in signals, in procedure calls and in create operations.

During system start-up there is no way to obtain the PId value for a static process instance at the output that starts a communication session. The receiver of the first signal must therefore be implicit, by using an output without TO.

To be able to handle outputs without TO, in SDL-92 types and in separate generated units, complete knowledge about the structure of channels and signal routes must be known at run-time. The same knowledge is also necessary if we want to check that there is a path from the sender to the receiver in an output with TO. As the information needed about channels and signal routes requires substantial amounts of memory, it would be nice, in applications with severe memory requirements, to be able to optimize this.

To remove all information about channels and signal routes from a generated application means two things:

  1. Output without TO cannot be used in SDL-92 types or in separate generated units.
  2. It is not possible to check that there is a path between the sender and the receiver at an output with TO.

The second limitation is no problem as this is the way we probably want it in a running application (during debugging the test ought to be used, but not in the application).

The first limitation, that output without TO cannot be used, is however more difficult. In an SDL system not using the OO concepts (block type, process type, and so on) and not using separate generation there are no problems, but otherwise such outputs are necessary at the system start-up phase to establish communication between processes in different blocks. The purpose of this abstract data type is to provide a way to establish PId literals and thereby to be able to avoid outputs without TO.

The Data Type PIdLit

Caution!

The PIdLit data type should only be used in the way described here to introduce synonyms referring to static process instances. Other usage may not work!

If you are using this data type in a system that is to be validated using the SDL Explorer there are two additional requirements:

  • Only process types with the number of instances equal to (N,N) for N>0, may be referenced in PId_Lit operators.
  • No process type with the number of instances equal to (N,N) for N>0, may contain a Stop symbol, independently if a PId_Lit operator is used for the process type or not.

The data type PIdLit contains the following operators:

PId_Lit : xPrsIdNode -> PId;
PId_Lit : xPrsIdNode -> PIdList;
PId_Lit : xPrsIdNode, Integer -> PId;

In the file containing the data type (pidlist.pr) there is also a synonym that you may use to access the environment:

SYNONYM EnvPId PId = ...;

The type xPrsIdNode corresponds to the C type xPrsIdNode, which is used to refer to the process nodes in the symbol table tree built up by a generated application.

Use the first version of PId_Lit to obtain a synonym referring to the process instance of a process instance set with one initial instance.

Use the second version of PId_Lit to obtain a synonym of array type referring to the process instances of a process instance set with several initial instances.

Use the third version of PId_Lit to obtain a synonym referring to one of the process instances of a process instance set with several initial instances.

To introduce PId literals implemented as SDL synonyms, follow the steps below:

  1. Include the file pidlist.pr, which contains the implementation of the PIdList type, among the declarations in the system:
    /*#include 'pidlist.pr' */
    
    
    
  2. Identify which process instance sets that should have PId literals.
  3. Introduce #NAME directives for these process instance sets.
  4. Insert a #CODE directive among the declarations in the system. If. however, separate generation is not used, this #CODE directive need not be included.
    /*#CODE
    
    #HEADING
    
    extern XCONST struct xPrsIdStruct
    
           yPrsR_ProcessName1;
    
    extern XCONST struct xPrsIdStruct
    
           yPrsR_ProcessName2;
    
    extern XCONST struct xPrsIdStruct
    
           yPrsR_ProcessName3;
    
    */
    
    
    
    There should be an external definition for each process instance set identified in step 2. ProcessNameX should be replaced by the name introduced in the #NAME directives for the processes.
  5. For each process instance set that should have PId literals, introduce the following synonym definition in the system diagram.
    If the process type has one initial instance:
      SYNONYM Name1 PId =
    
        PId_Lit(#CODE('&yPrsR_ProcessName1'));
    
    
    
    If the process type has several initial instances:
      SYNONYM Name2 PIdList =
    
        PId_Lit(#CODE('&yPrsR_ProcessName2'));
    
    
    
    If the process type has several initial instances, but only one of them should be possible to refer to by a synonym:
      SYNONYM Name3 PId =
    
        PId_Lit(#CODE('&yPrsR_ProcessName3'), No);
    
    where No should be the instance number, that is, if No is 2, then the synonym Name3 should refer to the second instance of the process type.
    Of course, you may choose the names of the synonyms, but the string in the #CODE directive should be the xPrsIdNode variables in the extern definitions discussed in step 4 above.
  6. You may now use the synonyms of type PId that you defined in step 5 in expressions of PId type, for example as a receiver in the TO clause in an output. The synonym EnvPId, which refers to an environment process instance, can be used in the same way.
    Synonyms of type PIdList may be indexed (as an array) by an integer expression to obtain a PId value and may then be used in the same way as the synonyms of type PId. Indexes should be in the range 1 to the number of initial instances.

Example 554 : PIdList Data Type

OUTPUT Sig1 TO Name1;
OUTPUT Sig2 TO Name2(2);
OUTPUT Sig3 TO Name2(InstNo);
OUTPUT Sig4 TO EnvPId;
DECISION (Name3 = Sender);
TASK PId_Variable := Name2(1);
where InstNo is an integer variable or synonym and PId_Variable is a variable of type PId.

Note:

Note that no index check will be performed when indexing a PIdList synonym.


http://www.ibm.com/rational
Contents Index Previous Next