5. Data Exchange

Up to now the entities do something at the same time and can control the time, when they do something. Now they should really communicate, which means an entity sends data to the other entity. We also consider that sending a message costs time. The MoDeST-model:


01 action start_send_message_to_coordinator,
02 finish_send_message_to_coordinator,
03 receive_from_station,
05 work,
06 common_action1,
07 common_action2;
09 int data_coordinator;
10 int data;

11 process coordinator() {
13 do{
14   ::common_action1; 
15     receive_from_station{=data_coordinator+=data=}; 
16     common_action2   
17   }
18 }	

19 process station() {
20 clock timer;
21 do{
22   ::work; 
23     when(timer==5) 
24     start_send_message_to_coordinator{= timer=0, data=1 =};
25     common_action1;
26     when(timer==1) common_action2;
27     finish_send_message_to_coordinator{= data=0 =}
28   }
29 }

30 par{
31    ::coordinator()
32    ::station()
33 }

Download the model


The processes station() and coordinator() use the actions common_action1 and common_action2 to realize a synchronous communication. The global variable data is used to exchange data between both processes.

If the local clock variable timer reaches the value 5 the process station() put the data into the global variable data and resets the timer to 0 in an atomic step together with the action start_send_message. Now the action common_action1 in the process station() is active. If it is also active in the process coordinator() (which is the case), both processes execute the action and continue.

Sending a message costs 1 time unit. If the timer reaches 1 the action common_action2 in the process station() is active and if it is also active in the process coordinator (which is the case) each process executes the action common_action2 and continues.



back to start

back to 4. Introduction of Time

forward to 6. Avoiding Collisions