This is an old revision of the document!


In statement

An agent can communicate with its outside world using ports. Each port can be used both as an input or an output one. The current role of a port is determined by two factors:

  1. Connections to the port in the corresponding communication diagram – e.g. if a port p is used only as an input port for an one-way connection, it cannot be used as an output port.
  2. Statements used in the code layer – e.g. if a port p is used only as an argument of the in statement, it is an input port even if all its connections are two-way ones.

Any communication through a port can be a pure communication or a value passing combination.

In case of a pure communication, the in statement collects a signal (without specified value) through the statement port.

In case of a value passing communication, the in statement collects a value through the statement port (probably of a composed type) and assigns it to the statement parameter.

The in statement as a blocking communication is a single-step statement.

in p;
in p x;

Listing 1. In statement syntax (blocking version): p stands for a port name and x stands for a parameter name

Example 1

Figure 1. Example 1 communication diagram

agent A {
  out a;
}

agent B {
  in b;
}

Listing 1. Example 1 code layer

The only task of agent A is sending a signal through its port a and the only task of agent B is collecting a signal through its port b.

A communication between two active agents can be initialised by any of them. The agent that initialises it, performs the out statement to provide some information and waits for the second agent to take it, or performs the in statement to express its readiness to collect some information and waits until the second agent provides it.

Example 2

Figure 2. Example 2 communication diagram

agent A {
  out a;
}

agent B {
  in b;
}

agent C {
  in c;
}

Listing 2. Example 2 code layer

In the above example the port A.a is connected with two other ports, but only one of them will collect the signal. If both agents B and C are waiting for the signal, the choice between them is indeterministic. To avoid indeterminism, different priorities for these agents should be assigned.

A blocking communication means that if an agent initialises a communication with the in statement then it waits until another agent finishes it. The communication cannot be aborted.

A communication with a passive agent denotes a procedure call. See proc.

See also: Out statement

Go back