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

COVERAGE SUMMARY FOR SOURCE FILE [ProcessWithPriority.java]

nameclass, %method, %block, %line, %
ProcessWithPriority.java0%   (0/1)0%   (0/14)0%   (0/155)0%   (0/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProcessWithPriority0%   (0/1)0%   (0/14)0%   (0/155)0%   (0/40)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
ProcessWithPriority (SchedulerModel, ISchedulableProcess, IPriority): void 0%   (0/1)0%   (0/14)0%   (0/5)
changePriority (IPriority): boolean 0%   (0/1)0%   (0/34)0%   (0/9)
createNewInstance (ISchedulableProcess): IActiveProcess 0%   (0/1)0%   (0/31)0%   (0/7)
decreasePriority (): void 0%   (0/1)0%   (0/7)0%   (0/2)
getDynamicPriority (): IPriority 0%   (0/1)0%   (0/3)0%   (0/1)
getStaticPriority (): IPriority 0%   (0/1)0%   (0/3)0%   (0/1)
hasBonus (): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
resetDynamicPriority (): void 0%   (0/1)0%   (0/6)0%   (0/2)
setPriorityUpdateStrategy (IPriorityUpdateStrategy): void 0%   (0/1)0%   (0/4)0%   (0/2)
setToStaticPriorityWithBonus (int): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/23)0%   (0/1)
update (): void 0%   (0/1)0%   (0/5)0%   (0/3)
updatePriority (): void 0%   (0/1)0%   (0/9)0%   (0/3)

1package de.uka.ipd.sdq.scheduler.processes.impl;
2 
3import de.uka.ipd.sdq.probfunction.math.util.MathTools;
4import de.uka.ipd.sdq.scheduler.ISchedulableProcess;
5import de.uka.ipd.sdq.scheduler.SchedulerModel;
6import de.uka.ipd.sdq.scheduler.priority.IPriority;
7import de.uka.ipd.sdq.scheduler.priority.IPriorityUpdateStrategy;
8import de.uka.ipd.sdq.scheduler.processes.IActiveProcess;
9import de.uka.ipd.sdq.scheduler.queueing.IRunQueue;
10 
11public class ProcessWithPriority extends PreemptiveProcess {
12 
13        private IPriority staticPriority;
14        private IPriority dynamicPriority;
15        private IPriorityUpdateStrategy priorityUpdateStrategy;
16        private static boolean in_front_if_priority_changed = false;
17 
18        public ProcessWithPriority(SchedulerModel model, ISchedulableProcess process,
19                        IPriority staticPriority) {
20                super(model, process);
21                this.staticPriority = staticPriority;
22                this.dynamicPriority = staticPriority;
23                this.priorityUpdateStrategy = null;
24        }
25 
26        public IPriority getStaticPriority() {
27                return staticPriority;
28        }
29 
30        public IPriority getDynamicPriority() {
31                return dynamicPriority;
32        }
33 
34        public void setPriorityUpdateStrategy(
35                        IPriorityUpdateStrategy priorityUpdateStrategy) {
36                this.priorityUpdateStrategy = priorityUpdateStrategy;
37        }
38        
39        public void updatePriority(){
40                if (this.priorityUpdateStrategy != null)
41                        this.priorityUpdateStrategy.update(this);
42        }
43 
44        public boolean hasBonus() {
45                return dynamicPriority.greaterThan(staticPriority);
46        }
47 
48        /**
49         * Sets the dynamic priority back to the original, static priority.
50         */
51        public void resetDynamicPriority() {
52                changePriority(staticPriority);
53        }
54 
55        public void decreasePriority() {
56                changePriority(dynamicPriority.decrease());
57        }
58 
59        public boolean setToStaticPriorityWithBonus(int bonus) {
60                return changePriority(staticPriority.addBonus(bonus));
61        }
62 
63        private boolean changePriority(IPriority new_priority) {
64                if (!dynamicPriority.equals(new_priority)){
65                        IRunQueue q = null;
66                        if (isReady() && (q = getRunQueue()) != null){
67                                q.removeProcess(this);
68                                dynamicPriority = new_priority;
69                                q.addProcess(this,in_front_if_priority_changed);
70                        } else {
71                                dynamicPriority = new_priority;
72                        }
73                        return true;
74                }
75                return false;
76        }
77 
78        @Override
79        public void update() {
80                super.update();
81                updatePriority();
82        }
83        
84        @Override
85        public String toString() {
86                return getName() + " (" + MathTools.round( getTimeslice().getRemainingTime(), 0.1) +", " + getDynamicPriority() + ")";
87        }
88        
89        @Override
90        public IActiveProcess createNewInstance(ISchedulableProcess process) {
91        ProcessWithPriority p = new ProcessWithPriority(getModel(), process, staticPriority);
92                p.dynamicPriority = staticPriority;
93                if (this.priorityUpdateStrategy != null){
94                        p.priorityUpdateStrategy = this.priorityUpdateStrategy.cloneFor(p);
95                }
96                p.setTimeSlice(this.getTimeslice().clone());
97                p.updatePriority();
98                return p;
99        }
100}

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