### Modeling Example "State Machine Feedback Loop"

The task set of the modeling example “State Machine” is expanded further in this architecture pattern by combining the ideas behind the modeling example “State Machine” and “Feedback Loop”. This means that messages are exchanged in a loop and each sender/receiver is also a state machine. To achieve this, task T1 has two different internal states 0 and 1, and task T2 manages three consecutive states 0, 1, and 2. The state task T1 is currently in is sent via a message to task T2 before runnable R1 is called. If the content of the message sent from task T1 is 1, task T2 increases its internal state, e.g. from state 0 to 1, and if it is 0, task T2 decreases its internal state accordingly. Then, depending on the state task T2 is currently in, the according runnable (R2,0 for state 0, etc.) is executed. If the maximum or minimum state of task T2 is reached but the received message from task T1 tells task T2 to further increase or respectively decrease its internal state, task T2 sends a message to task T1. This message then causes task T1 to toggle its internal state which consequently results in a switch from increasing to decreasing or vice versa. In addition to this state machine feedback loop, other system architecture patterns are added to be executed concurrently in order to increase the complexity. The tasks T3 and T4 represent a client-server without reply and are equal to the tasks T1 and T2 respectively as described above in the modeling example “Client-Server without Reply”. T5 is a periodically activated task without any communication and identical to task T7 in the modeling example “Purely Periodic without Communication”.

The table below gives a detailed specification of the tasks and their parameters. The tasks are scheduled according fixed-priority, preemptive scheduling and if not indicated otherwise, all events are active in order to get a detailed insight into the system’s behavior.

Task | Priority | Preemption | Multiple Task Activation Limit | Activation | Execution Time
--- | --- | --- | --- | --- | ---
T1 | 2 | FULL | 1 | Periodic | R1 | Uniform
Offset = 0 | Min = 9.9 * 106
Recurrence = 300 * 106 | Max = 10 * 106
T2 | 1 | FULL | 1 |  | R2,0 | Uniform
Min = 99
Max = 100
Periodic | R2,1 | Uniform
Offset = 15 * 106 | Min = 99 * 103
Recurrence = 250 * 106 | Max = 100 * 103
| R2,2 | Uniform
Min = 49.5 * 106
Max = 50 * 106
T3 | 4 | FULL | 1 | Periodic | R3 | Uniform
Offset = 0 | Min = 99 * 105
Recurrence = 100 * 106 | Max = 100 * 105
T4 | 3 | FULL | 1 |  | R4,x | Uniform
Min = 99
Max = 100
R4,1 | Uniform
Min = 990
Max = 1 * 103
Periodic | R4,2 | Uniform
Offset = 15 * 106 | Min = 49.5 * 103
Recurrence = 60 * 106 | Max = 50 * 103
| R4,3 | Uniform
Min = 990 * 103
Max = 1 * 106
R4,4 | Uniform
Min = 49.5 * 106
Max = 50 * 106
T5 | 0 | FULL | 1 |  | R5,1 | Uniform
Min = 59.4 * 106
Periodic | Max = 60 * 106
Offset = 0 | R5,2 | Uniform
Recurrence = 1000 | Min = 19.8 * 106
| Max = 20 * 106

In order to show the impact of changes to the model, the following consecutive variations are made to the model:

1) Initial Task Set
  For this variation, the tasks T1, and T2 of the table above are active.

2) Increase of Task Set Size I
  For this variation, the tasks T1, T2, T3, and T4 are active. That way the utilization of the system is increased.

3) Increase of Task Set Size II
  As from this variation on, all tasks are active. That way the utilization of the system is increased.

4) Inter-process Activation
  As from this variation on, task T2 gets activated by an inter-process activation from task T1, and task T4 by an inter-process activation from task T3 instead of being activated periodically. The inter-process activation in task T1 is performed right after the message to task T2 is written and consequently before the runnable R1 is called, and in task T3 task T4 is called right before runnable R3. That way, a direct connection between these tasks is established.

5) Event Frequency Increase
  As from this variation on, the periodicity of the tasks T1, T3, and T5 are shortened. For task T1, the value for the period is set to 220 * 106, the task T3 to 50 * 106, and for task T5 to 500 * 106. That way, the information density is increased.

6) Execution Time Fluctuation
  As from this variation on, the execution time distribution is widened for both tasks. Therefore, the maximum of the uniform distribution is increased by 1 percent so that the uniform distribution varies now by 2 percent. That way, the utilization of the system is increased, which results in extinct activations.

7) Activation
  As from this variation on, the maximum number of queued activation requests for both tasks is set to 2. That way, the problem with extinct activations resulting from the previous variation is solved.

8) Accuracy in Logging of Data State I
  For this variation, the data accesses in all tasks are omitted. Instead, all runnablea representing a state are executed equally random, meaning the runnables R2,0, R2,1, and R2,2 are each executed with a probability of 33 %, and the runnables R4,x, R4,1, R4,2, R4,3, and R4,4 each with a probability of 20 %. That way, only a limited insight into the system’s runtime behavior is available.

9) Accuracy in Logging of Data State II
  For this variation, just task events are active. That way, only a limited insight into the system’s runtime behavior is available.