#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

Application scheduling

Description

Scheduling the resources of host, fog device to application modules forms the second level of resource management. The default resource scheduler equally divides a device's resources among all active application modules. The application scheduling policy can be customized by overriding the method “updateAllocatedMips” inside the class FogDevice.

Source Code

protected void updateAllocatedMips(String incomingOperator) {

getHost().getVmScheduler().deallocatePesForAllVms();

for (final Vm vm : getHost().getVmList()) {

if (vm.getCloudletScheduler().runningCloudlets() > 0 || ((AppModule) vm).getName().equals(incomingOperator)) {

getHost().getVmScheduler().allocatePesForVm(vm, new ArrayList() {

protected static final long serialVersionUID = 1L;

{

add((double) getHost().getTotalMips());

}

});

} else {

getHost().getVmScheduler().allocatePesForVm(vm, new ArrayList() {

protected static final long serialVersionUID = 1L;

{

add(0.0);

}

});

}

}

updateEnergyConsumption();

}

private void updateEnergyConsumption() {

double totalMipsAllocated = 0;

for (final Vm vm : getHost().getVmList()) {

AppModule operator = (AppModule) vm;

operator.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(operator).getVmScheduler()

.getAllocatedMipsForVm(operator));

totalMipsAllocated += getHost().getTotalAllocatedMipsForVm(vm);

}

System.out.println("number of vm :" + getHost().getVmList().size() + " on Fogdevice :" + getName());

double timeNow = CloudSim.clock();

double currentEnergyConsumption = getEnergyConsumption();

double newEnergyConsumption = currentEnergyConsumption + (timeNow - lastUtilizationUpdateTime) * getHost().getPowerModel().getPower(lastUtilization);

setEnergyConsumption(newEnergyConsumption);

double currentCost = getTotalCost();

double newcost = currentCost + (timeNow - lastUtilizationUpdateTime) * getRatePerMips() * lastUtilization * getHost().getTotalMips();

setTotalCost(newcost);

lastUtilization = Math.min(1, (double) (totalMipsAllocated / (double) getHost().getTotalMips()));

System.out.println("allocated mips for vm :" + totalMipsAllocated + " host total mips :" + getHost().getTotalMips());

System.out.println("Fogdevice name :" + getName() + " Utilization :" + lastUtilization);

lastUtilizationUpdateTime = timeNow;

}


Output