SchmidMottok.java 2.68 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 15 16 17

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

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

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

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

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

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

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

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

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

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

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

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

        return responseTime;
    }

}