Index: DCWoRMS/trunk/src/schedframe/resources/computing/description/ComputingResourceDescription.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/resources/computing/description/ComputingResourceDescription.java	(revision 477)
+++ DCWoRMS/trunk/src/schedframe/resources/computing/description/ComputingResourceDescription.java	(revision 512)
@@ -33,4 +33,5 @@
 	protected AirThroughputProfile airThroughputProfile;
 	protected Location location;
+	protected String category;
 	//protected Parameters parameters;
 
@@ -40,4 +41,5 @@
 
 		initId(computingResource);
+		this.category = computingResource.getType();
 
 		if (computingResource.getComputingResourceTypeChoiceSequence() != null) {
@@ -263,5 +265,7 @@
 	}
 
-
+	public String getCategory() {
+		return category;
+	}
 
 }
Index: DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java	(revision 495)
+++ DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java	(revision 512)
@@ -66,7 +66,7 @@
 	}
 	
-	public Map<String, PState> getSupportedPStates() throws NoSuchFieldException {
+	public Map<String, PState> getSupportedPStates() {
 		if(supportedPStates == null)
-			throw new NoSuchFieldException("Supported p-states are not defined.");
+			return new HashMap<String, PState>();
 		return supportedPStates;
 	}
Index: DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java	(revision 506)
+++ DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java	(revision 512)
@@ -1,7 +1,4 @@
 package schedframe.resources.computing.profiles.energy.power.ui;
 
-
-import gridsim.GridSimTags;
-import gridsim.dcworms.DCWormsTags;
 
 import java.util.Map;
@@ -15,6 +12,4 @@
 import schedframe.resources.computing.profiles.energy.power.PowerStateName;
 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.units.CpuSpeed;
-import schedframe.resources.units.StandardResourceUnitName;
 
 public class ProcessorPowerInterface extends ComputingResourcePowerInterface {
@@ -26,9 +21,5 @@
 		super(resource, pp);
 		currentPowerState = StandardPowerStateName.ON;
-		try {
-			currentPState = getSupportedPStates().get("P0");
-		} catch (NoSuchFieldException e) {
-			currentPState = null;
-		}
+		currentPState = getSupportedPStates().get("P0");
 	}
 	
@@ -53,17 +44,14 @@
 	}
 	
-	public Map<String, PState> getSupportedPStates() throws NoSuchFieldException {
+	public Map<String, PState> getSupportedPStates() {
 		return powerProfile.getSupportedPStates();
 	}
 	
 	public boolean supportPState(PState pState) {
-		try {
-			for(String pStateName: getSupportedPStates().keySet()){
-				if(pState.getName().equals(pStateName)){
-					return true;
-				}
+
+		for(String pStateName: getSupportedPStates().keySet()){
+			if(pState.getName().equals(pStateName)){
+				return true;
 			}
-		} catch (NoSuchFieldException e) {
-			return false;
 		}
 		return false;
@@ -71,12 +59,8 @@
 	
 	public boolean setPState(String pStateName){
-		PState newPState;
-		try {
-			newPState = getSupportedPStates().get(pStateName);
-		} catch (NoSuchFieldException e) {
-			return false;
-		}
+		PState newPState = getSupportedPStates().get(pStateName);
 
-		if(newPState != currentPState){
+
+		if(newPState != null && newPState != currentPState){
 			//double factor = newPState.getFrequency()/currentPState.getFrequency();
 			currentPState = newPState;
@@ -97,13 +81,10 @@
 
 	public boolean setFrequency(double freq) {
-		try {
-			for(String pStateName: getSupportedPStates().keySet()){
-				if(getSupportedPStates().get(pStateName).getFrequency() == freq){
-					setPState(pStateName);
-					return true;
-				}
+
+		for(String pStateName: getSupportedPStates().keySet()){
+			if(getSupportedPStates().get(pStateName).getFrequency() == freq){
+				setPState(pStateName);
+				return true;
 			}
-		} catch (NoSuchFieldException e) {
-			return false;
 		}
 		return false;
Index: DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java	(revision 495)
+++ DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java	(revision 512)
@@ -46,4 +46,5 @@
 	protected String name;
 	protected ResourceType type;
+	protected String category;
 	protected ResourceStatus status;
 
@@ -63,4 +64,5 @@
 		this.type = resDesc.getType();
 		this.name = resDesc.getId();
+		this.category = resDesc.getCategory();
 		this.status = ResourceStatus.FREE;
 		this.extensionList = new ExtensionListImpl(1);
@@ -230,4 +232,8 @@
 	}
 	
+	public String getCategory(){
+		return category;
+	}
+	
 	public PowerInterface getPowerInterface(){
 		if (extensionList != null) {
@@ -297,11 +303,10 @@
 	public void initiate(){
 		
-		ResourceEventCommand rec = new ResourceEventCommand(this);
+		/*ResourceEventCommand rec = new ResourceEventCommand(this);
 		EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller");
 		event.setReason(EventReason.SIM_INIT);
-		rec.execute(event);
-		
-		rec = new ResourceEventCommand(this);
-		event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller");
+		rec.execute(event);*/
+		ResourceEventCommand rec = new ResourceEventCommand(this);
+		EnergyEvent event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller");
 		event.setReason(EventReason.SIM_INIT);
 		rec.execute(event);
Index: DCWoRMS/trunk/src/schedframe/ResourceController.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/ResourceController.java	(revision 490)
+++ DCWoRMS/trunk/src/schedframe/ResourceController.java	(revision 512)
@@ -18,5 +18,5 @@
 	protected static Scheduler scheduler;
 	protected static List<ComputingResource> computingResources;
-	protected Deque<Initializable> toInit;
+	protected List<Initializable> toInit;
 	protected Set<String> compResLayers;
 	
@@ -137,9 +137,9 @@
 	}
 
-	public void setInitList(Deque<Initializable> toI) {
+	public void setInitList(List<Initializable> toI) {
 		toInit = toI;
 	}
 
-	public Deque<Initializable> getToInit() {
+	public List<Initializable> getToInit() {
 		return toInit;
 	}
Index: DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java
===================================================================
--- DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java	(revision 497)
+++ DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java	(revision 512)
@@ -9,6 +9,4 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.events.scheduling.TaskFinishedEvent;
-import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent;
 import schedframe.resources.ResourceStatus;
 import schedframe.resources.computing.ComputingResource;
@@ -18,5 +16,4 @@
 import schedframe.resources.units.ResourceUnitName;
 import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.UsedResourcesList;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -29,5 +26,4 @@
 import schedframe.scheduling.tasks.TaskInterface;
 import schedframe.scheduling.tasks.WorkloadUnit;
-import dcworms.schedframe.scheduling.Executable;
 
 public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalSchedulingPlugin {
@@ -51,5 +47,5 @@
 		
 		case START_TASK_EXECUTION:
-
+		case TASK_FINISHED:
 			// check all tasks in queue
 			for (int i = 0; i < q.size(); i++) {
@@ -62,57 +58,8 @@
 					if (choosenResources  != null) {
 						addToSchedulingPlan(plan, task, choosenResources);
-						ProcessingElements pes = (ProcessingElements)choosenResources.get(StandardResourceUnitName.PE);
-						List<Processor> processors =  new ArrayList<Processor>();
-						for(ComputingResource res : pes){
-							processors.add((Processor) res);
-						}
-						adjustFrequency(ResourceStatus.BUSY,processors);
 					} 
 				}
 			}
-			break;
-			
-		case TASK_FINISHED:
-			TaskFinishedEvent finEvent = (TaskFinishedEvent) event;
-			Executable exec = (Executable) jobRegistry.getExecutable(finEvent.getJobId(), finEvent.getTaskId());
-			UsedResourcesList usedResourcesList = exec.getUsedResources();
-			ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE);
-			List<Processor> processors =  new ArrayList<Processor>();
-			for(ComputingResource res : pes){
-				processors.add((Processor) res);
-				allocatedCPUs.add((Processor) res);
-			}
-			adjustFrequency(ResourceStatus.FREE, processors);
-			break;
-			
-		case TASK_REQUESTED_TIME_EXPIRED:
-			TaskRequestedTimeExpiredEvent timExpEvent = (TaskRequestedTimeExpiredEvent) event;
-			exec = (Executable) jobRegistry.getExecutable(timExpEvent.getJobId(), timExpEvent.getTaskId());
-			usedResourcesList = exec.getUsedResources();
-			pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE);
-			processors =  new ArrayList<Processor>();
-			for(ComputingResource res : pes){
-				allocatedCPUs.remove((Processor) res);
-			}
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				WorkloadUnit job = q.get(i);
-				TaskInterface<?> task = (TaskInterface<?>) job;
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources  != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-						pes = (ProcessingElements)choosenResources.get(StandardResourceUnitName.PE);
-						processors =  new ArrayList<Processor>();
-						for(ComputingResource res : pes){
-							processors.add((Processor) res);
-						}
-						adjustFrequency(ResourceStatus.BUSY, processors);
-					} 
-				}
-			}
-			break;
+			adjustFrequency(resourceManager.getProcessors());
 		}
 		return plan;
@@ -160,31 +107,21 @@
 		return map;
 	}
+	
+	private void adjustFrequency(List<Processor> processors){
 
-	private void adjustFrequency(ResourceStatus status, List<Processor> processors){
-		switch(status){
-		case BUSY:
-			for(Processor cpu: processors){
-				try {
-					if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0"))
-						cpu.getPowerInterface().setPState("P0");
-				} catch (NoSuchFieldException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
+		for(Processor cpu: processors){
+			if(cpu.getStatus() == ResourceStatus.FREE) {
+				if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3"))
+					cpu.getPowerInterface().setPState("P3");
 			}
-			break;
-		case FREE:
-			for(Processor cpu: processors){
-				try {
-					if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3"))
-						cpu.getPowerInterface().setPState("P3");
-				} catch (NoSuchFieldException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
+			else{
+				if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0"))
+					cpu.getPowerInterface().setPState("P0");
 			}
-			break;
+
 		}
+
 	}
 
+
 }
Index: DCWoRMS/trunk/src/simulator/DataCenterWorkloadSimulator.java
===================================================================
--- DCWoRMS/trunk/src/simulator/DataCenterWorkloadSimulator.java	(revision 494)
+++ DCWoRMS/trunk/src/simulator/DataCenterWorkloadSimulator.java	(revision 512)
@@ -262,6 +262,5 @@
 		ResourceController rc = resourceReader.read();
 
-		while(!rc.getToInit().isEmpty()){
-			Initializable initObj = rc.getToInit().pop();
+		for(Initializable initObj: rc.getToInit()){
 			initObj.initiate();
 		}
Index: DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java
===================================================================
--- DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 501)
+++ DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 512)
@@ -331,5 +331,5 @@
 						energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
 						
-						EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+						EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
 						if(resourceController.getComputingResources().contains(resource)) {
 							if( een != null /*&& een.getPp() != null*/ ){
@@ -339,5 +339,5 @@
 						} else if( een != null && een.getPowerProfile() != null ){
 							ComputingResource parent = resource.getParent();
-							een = (EnergyExtension )(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+							een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
 							boolean top = true;
 							while(parent != null){
Index: DCWoRMS/trunk/src/simulator/reader/ResourceReader.java
===================================================================
--- DCWoRMS/trunk/src/simulator/reader/ResourceReader.java	(revision 509)
+++ DCWoRMS/trunk/src/simulator/reader/ResourceReader.java	(revision 512)
@@ -9,4 +9,6 @@
 import java.util.ArrayDeque;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Deque;
 import java.util.HashMap;
@@ -27,4 +29,5 @@
 import schedframe.ResourceController;
 import schedframe.exceptions.ResourceException;
+import schedframe.resources.Resource;
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
@@ -51,5 +54,5 @@
 
 	protected ResourceCalendar resourceCalendar;
-	protected Deque<Initializable> toInit = new ArrayDeque<Initializable>();
+	protected List<Initializable> toInit = new ArrayList<Initializable>();
 	
 	private ExecutionTimeEstimationPlugin execTimeEstimationPlugin;
@@ -85,4 +88,5 @@
 
 		ResourceController rc = new ResourceController(mainScheduler, computingResources);
+		Collections.sort(toInit, new ResourceTypeComparator(new ArrayList<String>(compResLayers)));
 		rc.setInitList(toInit);
 		rc.setCompResLayers(compResLayers);
@@ -430,3 +434,21 @@
 	}
 	
+	class ResourceTypeComparator implements Comparator<Initializable>{
+		
+		List<String> order;
+		ResourceTypeComparator(List<String> order) {
+			this.order = order;
+		}
+		public int compare(Initializable init1, Initializable init2) {
+			String type1 = ((Resource)init1).getType().getName();
+			String type2 = ((Resource)init2).getType().getName();
+			if(order.indexOf(type1) > order.indexOf(type2))
+				return -1;
+			else if (order.indexOf(type1) < order.indexOf(type2))
+				return 1;
+			else return 0;
+			
+		}
+	}
+	
 }
