1 | package de.uka.ipd.sdq.scheduler.queueing.runqueues; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | import de.uka.ipd.sdq.scheduler.processes.IActiveProcess; |
7 | import de.uka.ipd.sdq.scheduler.queueing.IProcessQueue; |
8 | import de.uka.ipd.sdq.scheduler.queueing.IRunQueue; |
9 | import de.uka.ipd.sdq.scheduler.resources.IResourceInstance; |
10 | |
11 | |
12 | public class SingleRunQueue extends AbstractRunQueue { |
13 | |
14 | private IProcessQueue process_queue; |
15 | |
16 | public SingleRunQueue(IProcessQueue queue_prototype) { |
17 | this.process_queue = queue_prototype.createNewInstance(); |
18 | } |
19 | |
20 | @Override |
21 | protected int numWaitingProcesses() { |
22 | return process_queue.size(); |
23 | } |
24 | |
25 | @Override |
26 | public IActiveProcess getNextRunnableProcess(IResourceInstance instance) { |
27 | return process_queue.getNextRunnableProcess(instance); |
28 | } |
29 | |
30 | public IActiveProcess getNextRunnableProcess() { |
31 | return process_queue.getNextRunnableProcess(); |
32 | } |
33 | |
34 | @Override |
35 | public boolean removePendingProcess(IActiveProcess process) { |
36 | return process_queue.remove(process); |
37 | } |
38 | |
39 | public IRunQueue createNewInstance() { |
40 | return new SingleRunQueue(process_queue); |
41 | } |
42 | |
43 | public List<IActiveProcess> identifyMovableProcesses( |
44 | IResourceInstance targetInstance, boolean prio_increasing, boolean queue_ascending, int processes_needed) { |
45 | List<IActiveProcess> process_list = new ArrayList<IActiveProcess>(); |
46 | process_queue.identifyMovableProcesses(targetInstance,prio_increasing,queue_ascending,processes_needed, process_list); |
47 | return process_list; |
48 | } |
49 | |
50 | public IProcessQueue getBestRunnableQueue( |
51 | IResourceInstance instance) { |
52 | return this.process_queue.getBestRunnableQueue(instance); |
53 | } |
54 | |
55 | @Override |
56 | public boolean containsPending(IActiveProcess process) { |
57 | return process_queue.contains(process); |
58 | } |
59 | |
60 | @Override |
61 | protected void addProcessToRunQueue(IActiveProcess process, boolean inFront) { |
62 | process_queue.add(process, inFront); |
63 | } |
64 | |
65 | public boolean processStarving(double threshold) { |
66 | return process_queue.processStarving(threshold); |
67 | } |
68 | |
69 | public void setWaitingTime(IActiveProcess process, double waiting) { |
70 | process_queue.setWaitingTime(process, waiting); |
71 | } |
72 | |
73 | public double getWaitingTime(IActiveProcess process) { |
74 | return process_queue.getWaitingTime(process); |
75 | } |
76 | |
77 | public List<IActiveProcess> getStarvingProcesses(double starvationLimit) { |
78 | return process_queue.getStarvingProcesses(starvationLimit); |
79 | } |
80 | |
81 | public void resetStarvationInfo() { |
82 | } |
83 | } |