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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractScheduler.java]

nameclass, %method, %block, %line, %
AbstractScheduler.java0%   (0/1)0%   (0/10)0%   (0/292)0%   (0/67)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractScheduler0%   (0/1)0%   (0/10)0%   (0/292)0%   (0/67)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
AbstractScheduler (SimActiveResource, IQueueingStrategy, boolean, StarvationB... 0%   (0/1)0%   (0/15)0%   (0/6)
forkNewProcess (IActiveProcess, IResourceInstance): void 0%   (0/1)0%   (0/7)0%   (0/2)
fromReadyToRunningOn (IActiveProcess, IResourceInstance): void 0%   (0/1)0%   (0/68)0%   (0/12)
fromRunningToReady (IActiveProcess, IResourceInstance, boolean): void 0%   (0/1)0%   (0/62)0%   (0/10)
fromRunningToWaiting (WaitingProcess, Deque, boolean): void 0%   (0/1)0%   (0/50)0%   (0/13)
fromWaitingToReady (WaitingProcess, Deque, IResourceInstance): void 0%   (0/1)0%   (0/48)0%   (0/12)
registerProcess (IActiveProcess, IResourceInstance): void 0%   (0/1)0%   (0/6)0%   (0/2)
stopProcess (IActiveProcess): void 0%   (0/1)0%   (0/6)0%   (0/3)
terminateProcess (IActiveProcess, IResourceInstance): void 0%   (0/1)0%   (0/22)0%   (0/6)

1package de.uka.ipd.sdq.scheduler.strategy.impl;
2 
3import java.util.Deque;
4 
5import scheduler.configuration.StarvationBoost;
6import de.uka.ipd.sdq.scheduler.LoggingWrapper;
7import de.uka.ipd.sdq.scheduler.processes.IActiveProcess;
8import de.uka.ipd.sdq.scheduler.processes.impl.PreemptiveProcess;
9import de.uka.ipd.sdq.scheduler.queueing.IQueueingStrategy;
10import de.uka.ipd.sdq.scheduler.resources.IResourceInstance;
11import de.uka.ipd.sdq.scheduler.resources.active.SimActiveResource;
12import de.uka.ipd.sdq.scheduler.resources.passive.WaitingProcess;
13import de.uka.ipd.sdq.scheduler.strategy.IScheduler;
14 
15public abstract class AbstractScheduler implements IScheduler {
16        protected SimActiveResource resource;
17 
18        protected IQueueingStrategy queueing_strategy;
19 
20        private boolean in_front_after_waiting;
21 
22        protected double scheduling_interval;
23        
24        protected StarvationBoost starvationBoost;
25 
26        public AbstractScheduler(SimActiveResource resource,
27                        IQueueingStrategy queueingStrategy, boolean in_front_after_waiting, StarvationBoost starvationBoost) {
28                super();
29                this.resource = resource;
30                this.queueing_strategy = queueingStrategy;
31                this.in_front_after_waiting = in_front_after_waiting;
32                this.starvationBoost = starvationBoost;
33        }
34 
35        
36        public void forkNewProcess(IActiveProcess process, IResourceInstance current) {
37                queueing_strategy.forkProcess(process, current, false);
38        }
39        
40        public void registerProcess(IActiveProcess p, IResourceInstance instance) {
41                queueing_strategy.registerProcess(p,instance);
42        }
43        
44        public void terminateProcess(IActiveProcess process, IResourceInstance current){
45                if (process.isRunning()){
46                        fromRunningToReady(process, current, true);
47                        queueing_strategy.terminateProcess(process);
48                        process.getLastInstance().schedulingInterrupt(0);
49                } else {
50                        queueing_strategy.terminateProcess(process);
51                }
52        }
53 
54        /**
55         * Marks the given process as executing on the specified resource instance.
56         * 
57         * @param process
58         * @param instance
59         */
60        protected void fromReadyToRunningOn(IActiveProcess process,
61                        IResourceInstance instance) {
62                LoggingWrapper.log(" From READY to RUNNING " + process + " on "
63                                + instance);
64                assert process != null;
65                assert process.isReady();
66                assert queueing_strategy.containsPending(process);
67                assert !instance.processAssigned();
68 
69                queueing_strategy.removePendingProcess(process);
70                process.setRunning();
71                queueing_strategy.setRunningOn(process, instance);
72 
73                instance.assign(process);
74                process.setLastInstance(instance);
75        }
76 
77        /**
78         * 
79         * @param process
80         */
81        protected void fromRunningToReady(IActiveProcess process, IResourceInstance current, boolean inFront) {
82                LoggingWrapper.log(" From RUNNING to READY Process " + process);
83                assert process.isRunning() : "Process must be in running state to return to pending queue!";
84                assert queueing_strategy.runningOn(process).equals(
85                                process.getLastInstance()) : "Inconstistant State of the last instance of the process.";
86                assert process.getLastInstance().getRunningProcess().equals(process) : "Inconsistent running state!";
87                queueing_strategy.removeRunning(process);
88                stopProcess(process);
89                process.setReady();
90                queueing_strategy.addProcess(process, current, inFront);
91        }
92 
93        
94        public void fromRunningToWaiting(WaitingProcess waiting_process,
95                        Deque<WaitingProcess> waiting_queue, boolean in_front) {
96                LoggingWrapper.log(" From RUNNING to WAITING Process "
97                                + waiting_process.getProcess());
98                IActiveProcess process = waiting_process.getProcess();
99                assert process.isRunning() : "Process must be in running state.";
100 
101                queueing_strategy.fromRunningToWaiting(process);
102                stopProcess(process);
103                process.setWaiting();
104                
105                if (in_front) {
106                        waiting_queue.addFirst(waiting_process);
107                } else {
108                        waiting_queue.addLast(waiting_process);
109                }
110                
111                process.getLastInstance().schedulingInterrupt(0);
112 
113                queueing_strategy.onSleep(process.getLastInstance());
114                
115        }
116 
117        private void stopProcess(IActiveProcess process) {
118                process.getLastInstance().release();
119                process.cancelProceedEvent();
120        }
121 
122        
123        public void fromWaitingToReady(WaitingProcess waiting_process,
124                        Deque<WaitingProcess> waitingQueue, IResourceInstance current) {
125                LoggingWrapper.log("From WAITING to READY Process "
126                                + waiting_process.getProcess());
127                IActiveProcess process = waiting_process.getProcess();
128                assert process.isWaiting() : "Process must be in waiting state";
129 
130                waitingQueue.remove(waiting_process);
131                process.setReady();
132                
133                ((PreemptiveProcess)process).getTimeslice().updateTimeForScheduling();
134                
135                queueing_strategy.fromWaitingToReady(process, current, in_front_after_waiting);
136                process.toNow();
137                process.update();
138                process.getLastInstance().schedulingInterrupt(0);
139        }
140}

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