Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Both sides next revision
alvis:diagrams [2015/04/08 20:33]
marcin [Ports and communication channels]
— (current)
Line 1: Line 1:
-====== Communication diagrams ====== 
- 
-===== Agents ===== 
- 
- 
-There are two kinds of agents in Alvis. **Active agents** perform some activities and are similar to tasks in Ada programming language. Each of them can be treated as a thread of control in a concurrent or distributed system. On the other hand, **passive agents** do not perform any individual activity, and are similar to protected objects (shared variables). Passive agents provide mechanism for the mutual exclusion and data synchronisation.  
- 
-A **communication diagram** is a hierarchical graph whose nodes may represent both agents (**active** or **passive**) and parts of the model from the lower level. They are the only way in the Alvis modelling language, to point out agents that communicate one with another. Moreover, the diagrams allow programmers to combine sets of agents into modules that are also represented as agents (called **hierarchical agents**).  
- 
-{{:alvis:agents.png|agents}} 
- 
-**Fig. 1. ** From left: active agent, passive agent, hierarchical agent 
- 
- 
-**Active agents** are drawn as rounded boxes while passive ones as rectangles. An **agent's identifier** (name) is placed inside the corresponding shape.  The first character of the identifier must be an upper-case letter. Other characters (if any) must be alphabetic characters, either upper-case or lower-case, digits, or an underscore. **Alvis identifiers are case sensitive**. Moreover, the Alvis keywords cannot be used as identifiers. Names of agents that are initially activated (represent running processes) are **underlined**. 
- 
-===== Ports and communication channels ===== 
- 
-An agent can communicate with other agents through **ports**. Ports are drawn as circles placed at the edges of the corresponding rounded box or rectangle. Each agent port must have a unique identifier (name) assigned, but ports of different agents may have the same identifier assigned. A **port's identifier** (name) is placed inside the corresponding rounded box/rectangle next to the port. It must fulfill the same requirements as agents' identifiers but its first character must be a lower-case letter.  
- 
-A **communication channel** is defined explicitly between two agents and connects two ports. Communication channels are drawn as lines (or broken lines). An arrowhead points out the input port for the particular connection. Communication channels without arrowheads represent pairs of connections with opposite directions.  
- 
-{{ :alvis:example2.png |}} 
- 
-**Fig. 2.** One-way (with arrowhead) and two-way communication channels 
- 
-All ports have the same graphical representation regardless of the fact whether they are used as input or output ones. However, we can distinguished some subsets of ports based on the role they play in a model. 
- 
-  * **Input ports** are ports with at least one two-way connection or at least one one-way connection such that such a port is the input port for the connection. 
-  * **Output ports** are ports with at least one two-way connection or at least one one-way connection such that such a port is the output port for the connection. 
-  * **Procedure ports** are ports of passive agents that represent procedures (services) - each of them is an argument of the **proc statement**. 
- 
-An input port can be used an argument of the **in** statement. Similarly, an output port can be used an argument of the **out** statement. 
- 
-{{ :alvis:connections1.png?nolink |}} 
- 
-**Fig. 3.** Example of connections among active agents 
- 
- 
-Let us consider the communication diagram shown in Fig. 3. Port //b// is an input but not output port. It means that it cannot be used to send any signals/values from agent //B//. On the other hand, port //c// is both an input and output port.  
-Thus, it can play a double role in the model. It should be underlined that it is not necessary to use port //c// both as an argument of the **in** and **out statements**, but the two-way connection gives such an opportunity.  
- 
-In the diagram represented in Fig. 3 signals or/and values can be send between agents //A// and //C// in any directions, while agent //B// can only collect signals or/and values sent by agent //A//. In other words, if agent //A// initialises a communication providing a signal/value to port //a//, the value can be collected (if suitable statements are used) by agent //B// or //C//. If agent //A// initialises a communication demanding a signal/value on port //a//, such a signal/value can be provided only by agent //B//. 
- 
-Connections with passive agents **must be** one-way ones. There are to possibilities: 
-  - A connection between an active agent port and a passive agent procedure port - the active agent **calls a procedure** of the passive agent. 
-  - A connection between a passive agent non-procedure port and a passive agent procedure port - one passive agent calls, using a non-procedure port, a procedure of another passive agent. 
- 
-Alvis procedures are divided into input and output ones. An input procedure takes one argument while an output one provides a single result. A port that represents an input procedure may be used in connections only as an input port. On the other hand, a port that represents an output procedure may be used only as an output port. In case of passive agents, non-procedures ports only can be both input and output ones. 
- 
-{{ :alvis:philosophers.png?600 |}} 
- 
-**Fig. 4.** Communication diagram of the dining philosophers problem 
- 
-An example of a communication diagram for a dining philosophers problem is shown in Fig. 4. 
-Let us recall the problem briefly. Five philosophers are sitting around a circular table. Each philosopher spends his life alternately thinking and eating. There is a large bowl of spaghetti in the center of the table. There are also five plates at the table and five forks set between the plates. Eating spaghetti requires the use of two forks. Each philosopher thinks. When he gets hungry, he picks up the two forks that are closest to him. If a philosopher gets the chance to pick up both forks, he eats for a while. After a philosopher finishes eating, he puts down the forks and starts to think. 
- 
-Philosophers are represented by active agents with to ports used to to get and put right and left forks respectively. Forks are represented by passive agents with to procedures: **get** representing taking a fork from the table and **put** representing putting it back.  
- 
-**[[:alvis:manual|Go back]]** 
- 
- 
- 
-