Index: DCWoRMS/branches/coolemall/src/test/cpusharing/RunExperiment.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/cpusharing/RunExperiment.java	(revision 1393)
+++ DCWoRMS/branches/coolemall/src/test/cpusharing/RunExperiment.java	(revision 1393)
@@ -0,0 +1,19 @@
+package test.cpusharing;
+import simulator.DataCenterWorkloadSimulator;
+
+
+public class RunExperiment {
+	
+	public static void main(String args[]){
+		RunExperiment runner = new RunExperiment();
+		runner.run();
+	}
+	
+	public void run(){
+		String args[] = {
+				"src/test/cpusharing/experiment1.properties"
+				};
+		DataCenterWorkloadSimulator.main(args);
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/cpusharing/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/cpusharing/FCFSBF_RandomPlugin.java	(revision 1393)
+++ DCWoRMS/branches/coolemall/src/test/cpusharing/FCFSBF_RandomPlugin.java	(revision 1393)
@@ -0,0 +1,101 @@
+package test.cpusharing;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// 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);
+					}
+				}
+			}
+
+			break;
+		}
+		return plan;
+	}
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		
+		List<Processor> processors = resourceManager.getProcessors();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			if (processors.size() < cpuRequest) {
+				return null;
+			}
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
+				//if (processors.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(processors.get(i));
+					cpuRequest--;
+				//}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/cpusharing/resources1.xml
===================================================================
--- DCWoRMS/branches/coolemall/src/test/cpusharing/resources1.xml	(revision 1393)
+++ DCWoRMS/branches/coolemall/src/test/cpusharing/resources1.xml	(revision 1393)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+	xsi:noNamespaceSchemaLocation="../../simulator/schemas/resources/DCwormsResSchema.xsd">
+	
+			
+	<timeEstimationPlugin>
+		<name>test.cpusharing.CPUSharingTimeEstimationPlugin</name>
+	</timeEstimationPlugin>
+	
+	<!-- Simple data center description -->
+	<resources>
+		<computingResource class="DataCenter" name="compRes">
+			<!-- Defined data center contains only 1 processor -->
+			<computingResource class="Processor" count="1"/>
+		</computingResource>
+		<scheduler class="Cluster" name="cluster">
+			<!-- Definition of scheduling plugin at cluster level -->
+			<schedulingPlugin>
+				<name>test.cpusharing.FCFSBF_RandomPlugin</name>
+				<frequency>100</frequency>
+			</schedulingPlugin>	
+			<!-- Reference to managed resources - cluster manages resources belonging to the defined data center -->
+			<managedComputingResources include="false">
+				<resourceName>compRes</resourceName>
+			</managedComputingResources>
+		</scheduler>	
+	</resources>
+
+</environment>
Index: DCWoRMS/branches/coolemall/src/test/cpusharing/experiment1.properties
===================================================================
--- DCWoRMS/branches/coolemall/src/test/cpusharing/experiment1.properties	(revision 1393)
+++ DCWoRMS/branches/coolemall/src/test/cpusharing/experiment1.properties	(revision 1393)
@@ -0,0 +1,26 @@
+# Use single *.swf file as workload description.
+
+# Path to xml file which describes resource characteristics.
+resdesc=src/test/cpusharing/resources1.xml
+
+# and swf file, which name is declared by readscenario.workloadfilename parameter.
+# Swf file must be placed in readscenario.inputfolder directory.  
+readscenario.workloadfilename=src/test/cpusharing/workload.swf
+
+# Choose directory where all result files should be placed.
+stats.outputfolder=src/test/cpusharing_result
+
+# Define the type and content of charts to generate
+
+# Gantt chart
+creatediagrams.gantt=true
+
+# Shows the execution times of tasks
+creatediagrams.tasks=true
+
+# Shows the waiting times of tasks
+creatediagrams.taskswaitingtime=true
+
+# Resource utilization chart - only for processors
+creatediagrams.resutilization=Processor
+
Index: DCWoRMS/branches/coolemall/src/test/cpusharing/CPUSharingTimeEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/cpusharing/CPUSharingTimeEstimationPlugin.java	(revision 1393)
+++ DCWoRMS/branches/coolemall/src/test/cpusharing/CPUSharingTimeEstimationPlugin.java	(revision 1393)
@@ -0,0 +1,65 @@
+package test.cpusharing;
+
+
+import java.util.Map;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import example.timeestimation.BaseTimeEstimationPlugin;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.units.PEUnit;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+
+
+/**
+ * 
+ * @author Marcin Krystek && Wojciech Piatek
+ *
+ */
+
+public class CPUSharingTimeEstimationPlugin extends BaseTimeEstimationPlugin{
+
+	/*
+	 * This method should return an estimation of time required to execute the task.
+	 * Requested calculation should be done based on the resources allocated for the task,
+	 * task description and task completion percentage.
+	 * 
+	 * Example implementation calculate the estimation based on cpu processing power.
+	 * There is also a simple assumption, that cpu processing power is a linear function
+	 * of number of allocated cpus and their speed.
+	 */
+	public double execTimeEstimation(SchedulingEvent event, ExecTask task,
+			Map<ResourceUnitName, ResourceUnit> allocatedResources,
+			double completionPercentage) {
+		
+		// collect all information necessary to do the calculation
+		PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE);
+		ProcessingElements pe = (ProcessingElements)peUnit;
+		
+		// obtain single pe speed
+		double speed = peUnit.getSpeed() / (double) new JobRegistryImpl(pe.get(0).getFullName()).getRunningTasks().size();
+
+		// number of used pe  
+		double cnt = peUnit.getUsedAmount();
+
+		// estimate remainingTaskLength
+		double remainingLength =  task.getLength() * (1 - completionPercentage/100);
+		
+		// do the calculation
+		double execTime = (remainingLength / (cnt * speed));
+
+		// if the result is very close to 0, but less then one millisecond then round this result to 0.001
+		if (Double.compare(execTime, 0.001) < 0) {
+			execTime = 0.001;
+		}
+
+		// time is measured in integer units, so get the nearest execTime int value.
+		execTime = Math.round(execTime);
+		return execTime;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/cpusharing/workload.swf
===================================================================
--- DCWoRMS/branches/coolemall/src/test/cpusharing/workload.swf	(revision 1393)
+++ DCWoRMS/branches/coolemall/src/test/cpusharing/workload.swf	(revision 1393)
@@ -0,0 +1,18 @@
+;Automatically generated workload description by the Grid Scheduling Simulator																																				
+;		j|		s|		w|		r|		c|		c|		m|		p|		t|		m|		s|		u|		g|		e|		q|		p|		p|		t|
+;		o|		u|		a|		u|		p|		p|		e|		r|		i|		e|		t|		i|		i|		x|		u|		a|		r|		h|
+;		b|		b|		i|		n|		u|		u|		m|		o|		m|		m|		a|		d|		d|		e|		e|		r|		e|		i|
+;		 |		m|		t|		t|		 |		 |		 |		c|		e|		 |		t|		 |		 |		c|		u|		t|		c|		n|
+;		 |		i|		 |		i|		a|		t|		u|		 |		 |		r|		u|		 |		 |		u|		e|		i|		 |		k|
+;		 |		t|		 |		m|		l|		i|		s|		r|		r|		e|		s|		 |		 |		t|		 |		t|		j|		 |
+;		 |		 |		 |		e|		l|		m|		e|		e|		e|		q|		 |		 |		 |		a|		n|		i|		o|		t|
+;		 |		 |		 |		 |		o|		e|		d|		q|		q|		 |		 |		 |		 |		b|		r|		o|		b|		i|
+;		 |		 |		 |		 |		c|		 |		 |		 |		 |		 |		 |		 |		 |		l|		 |		n|		 |		m|
+;		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		e|		 |		 |		 |		e|
+;StartTime: Mon Nov 03 00:00:00 CET 2008																																				
+;PUSpeed: 1																																				
+		0		0		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		1		10		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		2		20		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		3		30		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		4		40		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
