### Modeling Example 1

#### General information

Modeling Example 1 describes a simple system consisting of 4 Tasks, which is running on a dual core processor.
The following figure shows the execution footprint in a Gantt chart:
In the following sections, the individual parts of the AMALTHEA model for Modeling Example 1 are presented followed by a short description of its elements.

#### Hardware Model

The hardware model of Modeling Example 1 consists as already mentioned of a dual core processor.
The following gives a structural overview on the modeled elements.
There, the two cores, ‘Core_1’ and ‘Core_2’, have a static processing frequency of 100 MHz each, which is specified by the corresponding quartz oscillator ‘Quartz’.

#### Operating System Model

The operating system (OS) model defines in case of Modeling Example 1 only the needed Scheduler.
Since a dual core processor has to be managed, two schedulers are modeled correspondingly.
In addition to the scheduler definition used by the scheduler, in this case OSEK, a delay of 100 ticks is set, which represents the presumed time the scheduler needs for context switches.

Scheduler | Type | Algorithm | Delay
--- | --- | --- | ---
Scheduler_1 | Constant | OSEK | 100 ticks
Scheduler_2 | Constant | OSEK | 100 ticks

#### Mapping Model

The mapping model defines allocations between different model parts.
On the one hand, this is the allocation of processes to a scheduler. In case of Example 1, ‘Task_1’ and ‘Task_2’ are managed by ‘Scheduler_1’, while the other tasks are managed by ‘Scheduler_2’. Scheduler specific parameters are set here, too. For the OSEK scheduler these are ‘priority’ and ‘taskGroup’. Each task has a priority assigned according its deadline, meaning the one with the shortest deadline, ‘Task_1’, has the highest priority, and so on.
On the other hand the allocation of cores to a scheduler is set. For Modeling Example 1 two local schedulers were modeled. As a consequence, each scheduler manages one of the processing cores.
A comprehension of the modeled properties can be found in the following tables:

##### Executable Allocation with Scheduling Parameters

Scheduler | Process | priority | taskGroup
--- | --- | --- | ---
Scheduler_1 | Task_1 | 4 | 1
Scheduler_1 | Task_2 | 3 | 2
Scheduler_2 | Task_3 | 2 | 3
Scheduler_2 | Task_4 | 1 | 4

##### Core Allocation

Scheduler | Core
--- | ---
Scheduler_1 | Core_1
Scheduler_2 | Core_2

#### Software Model

##### Tasks

As already mentioned above, the software model of Modeling Example 1 consists exactly of four tasks, named ‘Task_1’ to ‘Task_4’. Each task is preemptive and also calls a definitive number of Runnables in a sequential order.
A comprehension of the modeled properties can be found in the following table:

Task | Preemption | MTA* | Deadline | Calls
--- | --- | --- | --- | ---
Task_1 | Preemptive | 1 | 75 ms | 1) Runnable_1_1
Task_2 | Preemptive | 1 | 115 ms | 1) Runnable_2_1
2) Runnable_2_2
Task_3 | Preemptive | 1 | 300 ms | 1) Runnable_3_1
2) Runnable_3_2
3) Runnable_3_3
Task_4 | Preemptive | 1 | 960 ms | 1) Runnable_4_1
2) Runnable_4_2
3) Runnable_4_3
4) Runnable_4_4

*MTA = Multiple Task Activation Limit

##### Runnables

In addition to the task, the software model also contains a definition of Runnables.
For Modeling Example 1, ten individual Runnables are defined.
The only function of those in this example is to consume processing resources.
Therefore, for each Runnable a constant number of instruction cycles is stated.
A comprehension of the modeled properties can be found in the following table:

Runnable | InstructionCycles
--- | ---
Runnable_1_1 | 1500000
Runnable_2_1 | 1500000
Runnable_2_2 | 1500000
Runnable_3_1 | 1000000
Runnable_3_2 | 2000000
Runnable_3_3 | 1000000
Runnable_4_1 | 1000000
Runnable_4_2 | 2000000
Runnable_4_3 | 3000000
Runnable_4_4 | 2000000

#### Stimuli Model

The stimulation model defines the activations of tasks.
Since the four tasks of Modeling Example 1 are activated periodically, four stimuli according their recurrence are modeled.
A comprehension of the modeled properties can be found in the following table:

Stimulus | Type | Offset | Recurrence
--- | --- | --- | ---
Stimulus_Task_1 | Periodic | 0 ms | 180 ms
Stimulus_Task_2 | Periodic | 0 ms | 200 ms
Stimulus_Task_3 | Periodic | 0 ms | 300 ms
Stimulus_Task_4 | Periodic | 0 ms | 1 s