Changeset 143 for xssim/trunk/src
- Timestamp:
- 03/15/12 16:06:56 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
xssim/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java
r104 r143 15 15 import schedframe.scheduling.events.SchedulingEvent; 16 16 import schedframe.scheduling.events.TaskFinishedEvent; 17 import schedframe.scheduling.events.TaskRequestedTimeExpiredEvent; 17 18 import schedframe.scheduling.plugin.grid.ModuleList; 18 19 import schedframe.scheduling.utils.ResourceParameterName; … … 33 34 public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalPlugin { 34 35 36 List<CPU> allocatedCPUs; 35 37 public FCFSCPUFreqScalingClusterLocalPlugin () { 38 allocatedCPUs = new ArrayList<CPU>(); 36 39 } 37 40 … … 79 82 for(ComputingResource res : pes){ 80 83 processors.add((CPU) res); 84 allocatedCPUs.add((CPU) res); 81 85 } 82 86 adjustFrequency(ResourceStatus.FREE, processors); … … 84 88 85 89 case TASK_REQUESTED_TIME_EXPIRED: 90 TaskRequestedTimeExpiredEvent timExpEvent = (TaskRequestedTimeExpiredEvent) event; 91 subTask = jobRegistry.getSubmittedTask(timExpEvent.getJobId(), timExpEvent.getTaskId()); 92 usedResourcesList = subTask.getUsedResources(); 93 pes = (ProcessingElements)usedResourcesList.get(usedResourcesList.size() - 1).getResourceUnits().get(ResourceParameterName.PROCESSINGELEMENTS); 94 processors = new ArrayList<CPU>(); 95 for(ComputingResource res : pes){ 96 allocatedCPUs.remove((CPU) res); 97 } 86 98 // check all tasks in queue 87 99 for (int i = 0; i < q.size(); i++) { … … 94 106 if (choosenResources != null) { 95 107 addToSchedulingPlan(plan, task, choosenResources); 96 108 pes = (ProcessingElements)choosenResources.get(ResourceParameterName.PROCESSINGELEMENTS); 97 109 processors = new ArrayList<CPU>(); 98 110 for(ComputingResource res : pes){ 99 111 processors.add((CPU) res); 100 112 } 101 adjustFrequency(ResourceStatus.BUSY, processors);113 adjustFrequency(ResourceStatus.BUSY, processors); 102 114 } 103 115 } … … 123 135 List<ComputingResource> choosenResources = null; 124 136 List<CPU> processors = resourceManager.getProcessors(); 137 processors.removeAll(allocatedCPUs); 125 138 if (processors.size() < cpuRequest) { 126 139 // log.warn("Task requires more cpus than is availiable in this resource."); … … 142 155 } 143 156 144 ProcessingElements result = new ProcessingElements( processors.get(0).getParent().getParent().getName());157 ProcessingElements result = new ProcessingElements(); 145 158 result.addAll(choosenResources); 146 159 map.put(ResourceParameterName.PROCESSINGELEMENTS, result); … … 153 166 case BUSY: 154 167 for(CPU cpu: processors){ 155 cpu.getPowerInterface().setPState(PStateType.P0); 168 if(cpu.getPowerInterface().getSupportedPStates().containsKey(PStateType.P0)) 169 cpu.getPowerInterface().setPState(PStateType.P0); 156 170 } 157 171 break; 158 172 case FREE: 159 173 for(CPU cpu: processors){ 160 cpu.getPowerInterface().setPState(PStateType.P3); 174 if(cpu.getPowerInterface().getSupportedPStates().containsKey(PStateType.P3)) 175 cpu.getPowerInterface().setPState(PStateType.P3); 161 176 } 162 177 break;
Note: See TracChangeset
for help on using the changeset viewer.