UCLA Parallel Computing Laboratory

blue beaded border

Code Modifications for Maisie to Parsec

Several changes to Maisie code are necessary before it can be used with the Parsec compiler.

Header Files

The header file, indicated at the begining of the code as "maisie.h", is still necessary. If the header file name is "mayc.h", please change it to "maisie.h".

Example:
#include "maisie.h"

Compilation of the Parsec source file will generate an ".mo" file, containing prototypes for entities and messages. The ".mo" file will then be recompiled.

ANCI C Format

All variable and parameter declarations in entities and friend functions must obey the ANSI C format. For the sake of consistency, it is desirable that all C functions declared in a Parsec program, to also use ANSI C format, although this is not enforced by the Parsec compiler.

Old Format:
entity job{ cpu, disk, dmean }
ename disk, cpu;
int dmean;
{
   message ack { }  ack1;
   message finish { } finish1;
   int i, t, end, start, t_wait, tid; 
   invoke cpu with req {self}; 
   . . . . 
New Format:
entity job{ ename cpu, ename disk, int dmean }
{
   message ack { }  ack1;
   message finish { } finish1;
   int i, t, end, start, t_wait, tid; 
   invoke cpu with req {self}; 
   . . . . 


Friend Functions

Friend functions may be defined inside or outside an entity and the definitions must follow ANSI C syntax rules. A friend function must also have been defined prior to its use within an entity.

If a function, say f has been defined, and is subsequently declared as a friend function within an entity, it is not necessary for the declaration to include the function prototype.

Message Declarations

All message type definitions must include the message type name, followed by the parameters in curly braces. The curly braces are required even in the definition of message types with no parameters (the previous version of the compiler allowed the curly braces to be omitted for parameterless messages).

Legal Syntax:
entity job{ ename cpu, ename disk, 
            int dmean }
{
   message ack { }  ack1;
   message finish{};
   int i, t, end, start, t_wait, tid; 
   invoke cpu with req {self}; 
   . . . . 
Illegal Syntax:
entity job{ ename cpu, ename disk, 
            int dmean }
{
   message ack ack1;
   message finish;
   int i, t, end, start, t_wait, tid; 
   invoke cpu with req {self}; 
   . . . . 

Maisie on the SP2 required every message type definition to also declare a variable of the type, even if such a variable was not required in the program. This is not necessary in Parsec.

The names of message types in a Parsec program are assumed to be global. In other words, a given identifier, say m1 can be used to define only one message type in a program. In the previous version, it was possible for a programmer to use m1 to define multiple message types (in the declaration of different entity types). Message definitions are global and the message variables are local.

Before:
entity job{ ename cpu, ename disk, 
            int dmean }
{
   message ack { }  ack1;
   message m1 { };
   int i, t, end, start, t_wait, tid; 
   invoke cpu with req {self}; 
   . . . . 


Recommended:
message ack { };
message m1 { };

entity job{ ename cpu, ename disk, 
            int dmean }
{
   message ack ack1;
   int i, t, end, start, t_wait, tid; 
   invoke cpu with req {self}; 
   . . . . 

Separate Compilation

If a program uses separate compilation where messages, functions, and entities that are declared in a file, say f1, are used in a file, say f2, it is required that f2 include the prototype of the externally referenced object in an appropriate extern declaration. For an external entity, it is necessary that its arguments are included in the prototype.
Example:
extern entity entity_in_other_file { int arg1, char *arg2, float arg3[]};

For external messages, the declaration should include the message paramaters.

Example:
extern message m1_from_other_file { int a, char c, . . . };

An external function can not be declared as a friend function for an entity.

Simulations

Sclock, zzcla, and zzmaxla functions now require a self argument.

Before:
sclock(void)
zzcla(lookahead)
zzmaxla(maxlookahead)
Now:
sclock(self)
zzcla(self, lookahead)
zzmaxla(self, maxlookahead)

New Features

Stacksize

Entities now contain an optional stack size parameter that takes a unary expression.
Example:
entity my_entity { int a, char *c, float d } [stacksize (unary_expression)]
{  . . . . }; 

Wildcard Message Type

Example:
entity channel{}
{
        message wildcard m1;

        wait until mtype (wildcard) {
                . . . . ;
                invoke receiver1 with any = msg.any;
                invoke receiver2 with any = m1;
                }
}

More information forthcoming as details are hammered out.


Information compiled by Monnica Terwilliger (monnica@cs.ucla.edu).
Return to Parsec Home Page

Updated: May 16, 1997.