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

COVERAGE SUMMARY FOR SOURCE FILE [QuantumTimeSlice.java]

nameclass, %method, %block, %line, %
QuantumTimeSlice.java0%   (0/1)0%   (0/14)0%   (0/224)0%   (0/54)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class QuantumTimeSlice0%   (0/1)0%   (0/14)0%   (0/224)0%   (0/54)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
QuantumTimeSlice (): void 0%   (0/1)0%   (0/12)0%   (0/5)
QuantumTimeSlice (double, int, int): void 0%   (0/1)0%   (0/47)0%   (0/10)
clone (): ITimeSlice 0%   (0/1)0%   (0/22)0%   (0/6)
fullReset (): void 0%   (0/1)0%   (0/9)0%   (0/3)
getRemainingTime (): double 0%   (0/1)0%   (0/3)0%   (0/1)
halfReset (): void 0%   (0/1)0%   (0/25)0%   (0/7)
isFinished (): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
punish (int): void 0%   (0/1)0%   (0/7)0%   (0/2)
reset (): void 0%   (0/1)0%   (0/9)0%   (0/3)
setExpired (): void 0%   (0/1)0%   (0/7)0%   (0/3)
substractTime (double): void 0%   (0/1)0%   (0/60)0%   (0/8)
updateTimeForBoosting (): void 0%   (0/1)0%   (0/9)0%   (0/3)
updateTimeForScheduling (): void 0%   (0/1)0%   (0/1)0%   (0/1)

1package de.uka.ipd.sdq.scheduler.timeslice.impl;
2 
3import de.uka.ipd.sdq.probfunction.math.util.MathTools;
4import de.uka.ipd.sdq.scheduler.timeslice.ITimeSlice;
5 
6 
7public class QuantumTimeSlice implements ITimeSlice {
8                
9        protected double remaining_time;
10        protected double timeslice;
11        protected int         remaining_quanta;
12        protected int         quanta;         // Windows default : 6
13        protected int min_quanta;         // Windows default : 2
14        
15        public QuantumTimeSlice(double timeslice, int quanta, int min_quanta) {
16                super();
17                
18                assert timeslice > 0 : "Timeslice must be larger than 0.";
19                assert quanta > 0 : "Quanta must be larger than 0.";
20                assert min_quanta > 0 : "Min Quanta must be larger than 0.";
21                
22                this.timeslice = timeslice;
23                this.quanta = quanta;
24                this.min_quanta = min_quanta;
25                this.remaining_time = 0;
26                this.remaining_quanta = 0;
27        }
28        
29        protected QuantumTimeSlice(){
30                this.timeslice = 0;
31                this.remaining_time = 0;
32                this.remaining_quanta = 0;
33        }
34 
35 
36        public boolean isFinished() {
37                return MathTools.equalsDouble(remaining_time, 0.0);
38        }
39        
40        
41        public void substractTime(double time) {
42                remaining_time -= time;
43                
44                double half = timeslice / 2;
45                if (remaining_time <= half && (remaining_time + time) > half){
46                        remaining_quanta -= (quanta / 2);
47                        if (MathTools.equalsDouble(remaining_time, 0)){
48                                remaining_quanta = 0;
49                        }
50                }
51                assert MathTools.lessOrEqual(0.0, remaining_time) : "Timeslice exceeded: " + remaining_time;
52        }
53 
54        
55        public void reset() {
56                remaining_time = timeslice;
57                remaining_quanta = quanta;
58        }
59 
60        
61        public void fullReset() {
62                remaining_time = timeslice;
63                remaining_quanta = quanta;
64        }
65 
66        
67        public double getRemainingTime() {
68                return remaining_time;
69        }
70 
71        
72        public void punish(int penalty) {
73                remaining_quanta--;
74        }
75 
76        
77        public void setExpired() {
78                this.remaining_time = 0;
79                this.remaining_quanta = 0;
80                
81        }
82        
83        @Override
84        public ITimeSlice clone() {
85                QuantumTimeSlice cts = new QuantumTimeSlice();
86                cts.timeslice = this.timeslice;
87                cts.quanta = this.quanta;
88                cts.remaining_time = this.remaining_time;
89                cts.remaining_quanta = this.remaining_quanta;
90                return cts;
91        }
92 
93        
94        public void halfReset() {
95                int factor = 0;
96                if (remaining_quanta > 4)
97                        factor = 2;
98                else if (remaining_quanta > 1)
99                        factor = 1;
100                remaining_time = timeslice/2 * factor;
101        }
102 
103        public void updateTimeForBoosting() {
104                if (remaining_quanta < min_quanta) {
105                        remaining_time = 0;
106                }
107        }
108 
109        public void updateTimeForScheduling() {
110        }
111}

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