This is an old revision of the document!


Proc statement

Passive agents are used to store data shared among agents and to avoid the simultaneous use of such data by two or more agents. They provide a set of procedures that can be called by other agents. Each procedure has its own port attached and a communication with a passive agent via that port is treated as the corresponding procedure call. Depending on the communication direction, such a procedure may be used to send or collect some data from the passive agent. Moreover, a passive agent may also contain internal non-procedure ports. Such ports are connected with another passive agents and are used to call other procedures inside procedures of the considered agent.

proc (g) p {...}

Listing 1. Proc statement syntax, where g stands for a guard and is optional and p stands for the corresponding port name.

A procedure is accessible for other agents only if the guard evaluates to True.

A communication with a passive agent is treated as a procedure call. It can be initialised either by an active agent or by a passive one from inside of its procedure. In case of an input procedure (a parameter is sent to the corresponding passive agent), it is called with the out statement. After a procedure is started, its performs its statements. It is necessary to put the in statement as one of them – the statement is used to collect the parameter, but it is not necessary to put the statement as the first procedure step.

Similarly, in case of an output procedure, it is called with the in statement. It is necessary to put the out statement as one of its statements. It is used to provide the result, but it is not necessary to put the statement at the end of the procedure. In any case, a procedure is finished if the exit statement has been performed. The exit statement can be used only after the in/out statement that corresponds to the procedure call.

Example

This is a part of a model only!

agent Buffer {
  i :: Int = 0;
  proc pop  { out pop i; exit; }
  proc push { in  push i; exit; }
}

Go back