EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.scheduler.priority.update]

COVERAGE SUMMARY FOR SOURCE FILE [SleepAverageDependentUpdate.java]

nameclass, %method, %block, %line, %
SleepAverageDependentUpdate.java0%   (0/1)0%   (0/4)0%   (0/97)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SleepAverageDependentUpdate0%   (0/1)0%   (0/4)0%   (0/97)0%   (0/21)
SleepAverageDependentUpdate (SchedulerModel, IActiveProcess, double, int): void 0%   (0/1)0%   (0/25)0%   (0/7)
cloneFor (ProcessWithPriority): SleepAverageDependentUpdate 0%   (0/1)0%   (0/11)0%   (0/1)
isInteractive (ProcessWithPriority): boolean 0%   (0/1)0%   (0/15)0%   (0/2)
update (ProcessWithPriority): boolean 0%   (0/1)0%   (0/46)0%   (0/11)

1package de.uka.ipd.sdq.scheduler.priority.update;
2 
3import de.uka.ipd.sdq.scheduler.SchedulerModel;
4import de.uka.ipd.sdq.scheduler.priority.IPriorityUpdateStrategy;
5import de.uka.ipd.sdq.scheduler.processes.IActiveProcess;
6import de.uka.ipd.sdq.scheduler.processes.impl.ProcessWithPriority;
7import de.uka.ipd.sdq.scheduler.sensors.impl.SleepAverageSensor;
8 
9 
10public class SleepAverageDependentUpdate implements IPriorityUpdateStrategy {
11 
12    private SchedulerModel model;
13        private SleepAverageSensor sleepAverageSensor;
14        
15        // parameters according to the Linux 2.6.22 scheduler.
16        private double max_sleep_average;
17        private int max_bonus;
18 
19        public SleepAverageDependentUpdate(SchedulerModel model, IActiveProcess process, double max_sleep_average, int max_bonus) {
20                sleepAverageSensor = new SleepAverageSensor(model, process, max_sleep_average, max_bonus);
21                process.addStateSensor(sleepAverageSensor);
22                this.model = model;
23                this.max_bonus = max_bonus;
24                this.max_sleep_average = max_sleep_average;
25        }
26 
27        /**
28         * Implementation according to the current Linux 2.6.18 Scheduler
29         */
30        public boolean update(ProcessWithPriority process) {
31                int current_bonus =  sleepAverageSensor.getCurrentBonus();
32                current_bonus -= max_bonus / 2;
33                process.setToStaticPriorityWithBonus(current_bonus);
34                if (process.getRunQueue() != null){
35                        double starvation_limit = max_sleep_average * process.getRunQueue().getCurrentLoad();
36                        boolean process_starving = process.getRunQueue().processStarving(starvation_limit);
37                        if (isInteractive(process) 
38                                        && process.getTimeslice().isFinished()
39                                        && !process_starving){
40                                process.getTimeslice().fullReset();
41                        }
42                }
43                return true;
44        }
45        
46 
47        
48        public boolean isInteractive(ProcessWithPriority p){
49//                int delta = p.getStaticPriority().getValue() * max_bonus / 40 + 2;
50//                IPriority threshold = p.getStaticPriority().addBonus(delta);
51//                IPriority prio = p.getDynamicPriority();
52//                return threshold.lessOrEqual(prio);
53                double sleep = sleepAverageSensor.interactiveSleep(p);
54                return sleepAverageSensor.getSleepAverage() > sleep;
55        }
56        
57        public SleepAverageDependentUpdate cloneFor(ProcessWithPriority process) {
58                return new SleepAverageDependentUpdate(model, process, max_sleep_average, max_bonus);
59        }
60        
61}

[all classes][de.uka.ipd.sdq.scheduler.priority.update]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov