SchmidMottok.java 2.74 KB
Newer Older
1 2
package mvd.jester.tests;

3 4
import java.util.HashMap;
import java.util.Map;
5
import java.util.Set;
6 7
import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo;
8
import mvd.jester.model.DagTask;
9
import mvd.jester.model.SortedTaskSet;
10
import mvd.jester.model.SystemManagerInterface;
11
import mvd.jester.model.Task;
12
import mvd.jester.priority.PriorityManager;
13
import mvd.jester.priority.RateMonotonic;
14
import mvd.jester.tests.TypeFunction.KnownStructureWithMaxThreads;
15 16 17 18

/**
 * SchmidMottok
 */
19
public class SchmidMottok extends AbstractTest<DagTask> {
20

21 22
    private final Map<Task, TerminationInfo> responseTimes;
    private final PriorityManager priorityManager;
23
    private final TypeFunction structure;
24

25
    public SchmidMottok(TypeFunction structure, final SystemManagerInterface manager) {
Michael Schmid committed
26
        super(manager);
27 28
        this.responseTimes = new HashMap<>();
        this.priorityManager = new RateMonotonic();
29
        this.structure = structure;
30 31 32
    }

    @Override
33 34 35 36 37
    public PriorityManager getPriorityManager() {
        return priorityManager;
    }

    @Override
38
    public SchedulingInfo runSchedulabilityCheck(final SortedTaskSet<DagTask> tasks) {
39
        responseTimes.clear();
40 41 42
        for (final DagTask t : tasks) {
            final long responseTime = calculateResponseTime(tasks, t);
            responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime));
43 44
        }

45
        return new SchedulingInfo(responseTimes.values());
46 47 48 49
    }

    @Override
    public String getName() {
50
        return "SchmidMottok" + "_" + structure.getType();
51 52
    }

53 54
    private long calculateResponseTime(final Set<DagTask> tasks, final DagTask task) {
        final long minimumWcet = task.getCriticalPath();
55 56 57 58 59
        long responseTime = minimumWcet;
        long previousResponseTime = 0;

        do {
            previousResponseTime = responseTime;
60
            double taskInterference = 0;
61
            for (final DagTask t : tasks) {
62
                if (t.getPeriod() < task.getPeriod()) {
63 64
                    final long numberOfThreads = structure.getNumberOfThreads(t);
                    for (int p = 0; p < numberOfThreads; ++p) {
65 66
                        taskInterference += Math.min(structure.getTaskInterference(t, responseTimes,
                                responseTime, p + 1), responseTime - minimumWcet + 1);
Michael Schmid committed
67
                    }
68 69 70
                }
            }

Michael Schmid committed
71
            taskInterference /= manager.getNumberOfProcessors();
72
            final double selfInterference = structure.getSelfInterference(task);
73

74
            final long totalInterference = (long) Math.floor(taskInterference + selfInterference);
75 76 77 78 79 80 81 82

            responseTime = minimumWcet + totalInterference;
        } while (previousResponseTime != responseTime);

        return responseTime;
    }

}