1 | package de.uka.ipd.sdq.scheduler.priority.update; |
2 | |
3 | import de.uka.ipd.sdq.scheduler.priority.IPriorityUpdateStrategy; |
4 | import de.uka.ipd.sdq.scheduler.processes.impl.ProcessWithPriority; |
5 | |
6 | |
7 | public class SetToBaseUpdate implements IPriorityUpdateStrategy { |
8 | |
9 | int currentTimeslices = 1; |
10 | int timeslices = 1; |
11 | |
12 | public SetToBaseUpdate(int timeslices) { |
13 | this.timeslices = timeslices; |
14 | this.currentTimeslices = timeslices; |
15 | } |
16 | |
17 | public boolean update(ProcessWithPriority process) { |
18 | if (process.getTimeslice().isFinished()){ |
19 | currentTimeslices --; |
20 | if (currentTimeslices <= 0){ |
21 | process.resetDynamicPriority(); |
22 | return false; |
23 | } |
24 | } |
25 | return true; |
26 | } |
27 | |
28 | public SetToBaseUpdate cloneFor(ProcessWithPriority process) { |
29 | return new SetToBaseUpdate(timeslices); |
30 | } |
31 | |
32 | } |