Commit 07dc14dd authored by rodrigo.calheiros's avatar rodrigo.calheiros

Solved issue #14: to avoid rounding problems, ResCloudlet processes length in…

Solved issue #14: to avoid rounding problems, ResCloudlet processes length in Instructions rather than Millions of Instructions.

parent 059beb41
...@@ -76,7 +76,7 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare ...@@ -76,7 +76,7 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
List<ResCloudlet> cloudletsToFinish = new ArrayList<ResCloudlet>(); List<ResCloudlet> cloudletsToFinish = new ArrayList<ResCloudlet>();
for (ResCloudlet rcl : getCloudletExecList()) { for (ResCloudlet rcl : getCloudletExecList()) {
rcl.updateCloudletFinishedSoFar((long) Math.ceil((timeSpan * getTotalCurrentAllocatedMipsForCloudlet(rcl, getPreviousTime())))); rcl.updateCloudletFinishedSoFar((long) (timeSpan * getTotalCurrentAllocatedMipsForCloudlet(rcl, getPreviousTime()) * 1000000));
if (rcl.getRemainingCloudletLength() == 0) { //finished: remove from the list if (rcl.getRemainingCloudletLength() == 0) { //finished: remove from the list
cloudletsToFinish.add(rcl); cloudletsToFinish.add(rcl);
......
...@@ -91,7 +91,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler { ...@@ -91,7 +91,7 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
capacity /= cpus; // average capacity of each cpu capacity /= cpus; // average capacity of each cpu
for (ResCloudlet rcl : getCloudletExecList()) { // each machine in the exec list has the same amount of cpu for (ResCloudlet rcl : getCloudletExecList()) { // each machine in the exec list has the same amount of cpu
rcl.updateCloudletFinishedSoFar((long) Math.ceil((capacity * timeSpam * rcl.getPesNumber()))); rcl.updateCloudletFinishedSoFar((long) (capacity * timeSpam * rcl.getPesNumber() * 1000000));
} }
if (getCloudletExecList().size() == 0 && getCloudletWaitingList().size() == 0) { // no more cloudlets in this scheduler if (getCloudletExecList().size() == 0 && getCloudletWaitingList().size() == 0) { // no more cloudlets in this scheduler
......
...@@ -69,7 +69,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler { ...@@ -69,7 +69,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
double timeSpam = currentTime - getPreviousTime(); double timeSpam = currentTime - getPreviousTime();
for (ResCloudlet rcl : getCloudletExecList()) { for (ResCloudlet rcl : getCloudletExecList()) {
rcl.updateCloudletFinishedSoFar((long) Math.ceil((getCapacity(mipsShare) * timeSpam * rcl.getPesNumber()))); rcl.updateCloudletFinishedSoFar((long) (getCapacity(mipsShare) * timeSpam * rcl.getPesNumber() * 1000000));
} }
if (getCloudletExecList().size() == 0) { if (getCloudletExecList().size() == 0) {
......
...@@ -227,7 +227,7 @@ public class ResCloudlet { ...@@ -227,7 +227,7 @@ public class ResCloudlet {
// In case a Cloudlet has been executed partially by some other grid // In case a Cloudlet has been executed partially by some other grid
// hostList. // hostList.
this.cloudletFinishedSoFar = cloudlet.getCloudletFinishedSoFar(); this.cloudletFinishedSoFar = cloudlet.getCloudletFinishedSoFar()*1000000;
} }
/** /**
...@@ -471,15 +471,14 @@ public class ResCloudlet { ...@@ -471,15 +471,14 @@ public class ResCloudlet {
* @post $result >= 0 * @post $result >= 0
*/ */
public long getRemainingCloudletLength() { public long getRemainingCloudletLength() {
long length = cloudlet.getCloudletTotalLength() - cloudletFinishedSoFar; long length = cloudlet.getCloudletTotalLength()*1000000 - cloudletFinishedSoFar;
// Remaining Cloudlet length can't be negative number. This can be // Remaining Cloudlet length can't be negative number.
// happening when this.updateCloudletFinishedSoFar() keep calling.
if (length < 0) { if (length < 0) {
length = 0; return 0;
} }
return length; return (long) Math.ceil(length/1000000);
} }
/** /**
...@@ -502,11 +501,11 @@ public class ResCloudlet { ...@@ -502,11 +501,11 @@ public class ResCloudlet {
cloudlet.setExecParam(wallClockTime, totalCompletionTime); cloudlet.setExecParam(wallClockTime, totalCompletionTime);
long finished = 0; long finished = 0;
if (cloudlet.getCloudletTotalLength() < cloudletFinishedSoFar) { if (cloudlet.getCloudletTotalLength()*1000000 < cloudletFinishedSoFar) {
finished = cloudlet.getCloudletLength(); finished = cloudlet.getCloudletLength();
} }
else { else {
finished = cloudletFinishedSoFar; finished = cloudletFinishedSoFar/1000000;
} }
cloudlet.setCloudletFinishedSoFar(finished); cloudlet.setCloudletFinishedSoFar(finished);
...@@ -515,7 +514,7 @@ public class ResCloudlet { ...@@ -515,7 +514,7 @@ public class ResCloudlet {
/** /**
* A method that updates the length of cloudlet that has been completed. * A method that updates the length of cloudlet that has been completed.
* *
* @param miLength cloudlet length in Million Instructions (MI) * @param miLength cloudlet length in Instructions (I)
* *
* @pre miLength >= 0.0 * @pre miLength >= 0.0
* @post $none * @post $none
......
...@@ -12,8 +12,6 @@ import java.util.ArrayList; ...@@ -12,8 +12,6 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.cloudbus.cloudsim.core.CloudSim;
/** /**
* Vm represents a VM: it runs inside a Host, sharing hostList * Vm represents a VM: it runs inside a Host, sharing hostList
* with other VMs. It processes cloudlets. This processing happens according * with other VMs. It processes cloudlets. This processing happens according
...@@ -136,6 +134,7 @@ public class Vm { ...@@ -136,6 +134,7 @@ public class Vm {
* @post $none * @post $none
*/ */
public double updateVmProcessing(double currentTime, List<Double> mipsShare) { public double updateVmProcessing(double currentTime, List<Double> mipsShare) {
setRecentlyCreated(false);
if (mipsShare != null) { if (mipsShare != null) {
return getCloudletScheduler().updateVmProcessing(currentTime, mipsShare); return getCloudletScheduler().updateVmProcessing(currentTime, mipsShare);
} }
...@@ -154,7 +153,7 @@ public class Vm { ...@@ -154,7 +153,7 @@ public class Vm {
//boolean mipsIsNull = true; //boolean mipsIsNull = true;
//if (CloudSim.clock() > 0) { //if (CloudSim.clock() > 0) {
//mipsIsNull = false; //mipsIsNull = false;
setRecentlyCreated(false); //
//} //}
// for (double mips : currentRequestedMips) { // for (double mips : currentRequestedMips) {
// if (mips > 0.0) { // if (mips > 0.0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment