Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionBoth sides next revision | ||
alvis:proc [2013/12/29 20:51] marcin [Proc statement] | — (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 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. | ||
- | |||
- | |||
- | |||
- | < | ||
- | proc (g) p {...} | ||
- | </ | ||
- | |||
- | **Listing 1. ** Proc statement syntax, where '' | ||
- | |||
- | A procedure is accessible for other agents only if the guard evaluates to '' | ||
- | |||
- | A communication between an active and a passive agent (a procedure call) can be initialised only by the former. Any procedure in Alvis uses only one either input or output parameter (or signal in case of parameterless communication). In case of an input procedure, an active agent calls the procedure using the **out** statement (and provides the parameter, if any, at the same time). If the corresponding passive agent is in the **waiting** mode and the procedure is accessible, the agent starts it in the active agent context. The passive agent collects the signal/ | ||
- | |||
- | ===== Example ===== | ||
- | |||
- | This is a part of a model only! | ||
- | |||
- | {{: | ||
- | |||
- | < | ||
- | agent Buffer { | ||
- | i :: Int = 0; | ||
- | proc pop { out pop i; } | ||
- | proc push { in push i; } | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | **[[: |