1 | package de.uka.ipd.sdq.scheduler.processes.impl; |
2 | |
3 | import de.uka.ipd.sdq.probfunction.math.util.MathTools; |
4 | import de.uka.ipd.sdq.scheduler.ISchedulableProcess; |
5 | import de.uka.ipd.sdq.scheduler.SchedulerModel; |
6 | import de.uka.ipd.sdq.scheduler.processes.IActiveProcess; |
7 | import de.uka.ipd.sdq.scheduler.timeslice.ITimeSlice; |
8 | |
9 | public class PreemptiveProcess extends ActiveProcess { |
10 | |
11 | private ITimeSlice timeslice = null; |
12 | |
13 | public PreemptiveProcess(SchedulerModel model, ISchedulableProcess process) { |
14 | super(model, process); |
15 | } |
16 | |
17 | @Override |
18 | protected void passTimeProcessing(double passedTime) { |
19 | super.passTimeProcessing(passedTime); |
20 | timeslice.substractTime(passedTime); |
21 | } |
22 | |
23 | public ITimeSlice getTimeslice(){ |
24 | return this.timeslice; |
25 | } |
26 | |
27 | public void setTimeSlice(ITimeSlice timeslice) { |
28 | this.timeslice = timeslice; |
29 | } |
30 | |
31 | @Override |
32 | public String toString() { |
33 | return super.toString() + " (" + MathTools.round( timeslice.getRemainingTime(), 0.1) +")"; |
34 | } |
35 | |
36 | @Override |
37 | public IActiveProcess createNewInstance(ISchedulableProcess process) { |
38 | PreemptiveProcess p = new PreemptiveProcess(getModel(), process); |
39 | p.timeslice = this.timeslice.clone(); |
40 | return p; |
41 | } |
42 | } |