Sunteți pe pagina 1din 17

ANAND INSTITUTE OF HIGHER TECHNOLOGY

OLD MAHABALIPURAM ROAD, KALASALINGAM NAGAR


KAZHIPATTUR, NEAR CHENNAI-603 103.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

MINI PROJECT
CS6712-GRID AND CLOUD COMPUTING LAB

(2019-2020)

Name : Ms.DEVIKA S

Reg. No. : 310116104017

Branch : B.E. COMPUTER SCIENCE AND ENGINEERING

Year : IV

Semester : VII
ANAND INSTITUTE OF HIGHER TECHNOLOGY
OLD MAHABALIPURAM ROAD, KALASALINGAM NAGAR
KAZHIPATTUR, NEAR CHENNAI-603 103.

BONAFIDE CERTIFICATE FOR MINI


PROJECT
Certified that this project report “VIRTUAL MACHINE AND TASK

SCHEDULING IN CLOUDSIM” is a Bonafide work of Ms.DEVIKA.S

RegisterNo:310116104017 of COMPUTER SCIENCE AND ENGINEERING, who

carried out the project work under my supervision during the Academic Year 2019 -

2020

Staff in charge MARKS:22/25


A.S.BALAJI,AP/CSE
Virtual machine and Task Scheduling in CloudSim

 
This procedure will help to understand the class hierarchies available in Cloudsim for
Virtual Machine and Cloudlet Scheduling. This blog post is supported with a video
lecture provided at the end, to have a better understanding of the implementation. Let’s
start with the basic terms.

Basics of Scheduling

In computers, Scheduling is a process of arranging the submitted jobs/task into a very


specific sequence of execution. It is an essential characteristic of any software operating
environment, which is handled by a very special program known as a scheduler.

Scheduler’s main objective is to keep the underlined hardware resources(primarily


processor) to be used effectively as well as efficient. In general, the scheduler may
prefer to have any of the following scheduling approaches:

● Space-shared: In this, the requested resources are allocated dedicatedly to the


requesting workload for execution and will be released only on
completion. Space-shared is also known as a batch process scheduling.
● Time-shared: In this, the requested resources would be shared among more than
one workload(task). The sharing is done based on time-sliced allocation where
each workload is allocated with a required resource for a defined time(e.g., 200
milliseconds). Once the defined time slice is over, the current workload execution
paused, and the resource is released. The released resource gets allocated to the
next workload for the same defined time slice, and this cycle goes on till the time
all the workloads execution is over. Time-shared is also known as round-
robin scheduling.

Scheduling in Cloud
As cloud computing is the virtualized operating environment, and the virtual
machines are the primary computing component which is responsible for the
execution of the workloads(tasks). The virtual machine(s) are powered by a physical
server host machine (i.e.) hardware. Depending on the requirement of the Virtual
Machine(VM) there could be ‘one to one’ or ‘many to one’ mapping between the VM
and host machine. That means in cloud computing the scheduling is done at both
the mapping levels that are:

● Virtual Machine to Host Machines


● Tasks to Virtual Machines

Both of VM to Host as well as Workload(task) to VM mappings may utilize space-share


or time-shared or any other specialized scheduling algorithm.

Scheduling in Cloudsim

The Cloudsim simulation toolkit framework has effectively addressed the Scheduling
scenario and implemented it as a set of the programmable class hierarchies with parent
class as:

1. VmScheduler
2. CloudletScheduler

VmScheduler

package org.cloudbus.cloudsim;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.cloudbus.cloudsim.lists.PeList;
/**
* VmScheduler is an abstract class that represents the policy
used by a VMM to share processing
* power among VMs running in a host.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
*/
public abstract class VmScheduler {

/** The peList. */


private List<? extends Pe> peList;

/** The map of VMs to PEs. */


private Map<String, List<Pe>> peMap;

/** The MIPS that are currently allocated to the


VMs. */
private Map<String, List<Double>> mipsMap;

/** The total available mips. */


private double availableMips;

/** The VMs migrating in. */


private List<String> vmsMigratingIn;

/** The VMs migrating out. */


private List<String> vmsMigratingOut;

/**
* Creates a new HostAllocationPolicy.
*
* @param pelist the pelist
* @pre peList != $null
* @post $none
*/
public VmScheduler(List<? extends Pe> pelist) {
setPeList(pelist);
setPeMap(new HashMap<String,
List<Pe>>());
setMipsMap(new HashMap<String,
List<Double>>());

setAvailableMips(PeList.getTotalMips(getPeList()));
setVmsMigratingIn(new
ArrayList<String>());
setVmsMigratingOut(new
ArrayList<String>());
}

/**
* Allocates PEs for a VM.
*
* @param vm the vm
* @param mipsShare the mips share
* @return $true if this policy allows a new VM in
the host, $false otherwise
* @pre $none
* @post $none
*/
public abstract boolean allocatePesForVm(Vm vm,
List<Double> mipsShare);

/**
* Releases PEs allocated to a VM.
*
* @param vm the vm
* @pre $none
* @post $none
*/
public abstract void deallocatePesForVm(Vm vm);

/**
* Releases PEs allocated to all the VMs.
*
* @pre $none
* @post $none
*/
public void deallocatePesForAllVms() {
getMipsMap().clear();

setAvailableMips(PeList.getTotalMips(getPeList()));
for (Pe pe : getPeList()) {

pe.getPeProvisioner().deallocateMipsForAllVms();
}
}

/**
* Gets the pes allocated for vm.
*
* @param vm the vm
* @return the pes allocated for vm
*/
public List<Pe> getPesAllocatedForVM(Vm vm) {
return getPeMap().get(vm.getUid());
}

/**
* Returns the MIPS share of each Pe that is
allocated to a given VM.
*
* @param vm the vm
* @return an array containing the amount of MIPS
of each pe that is available to the VM
* @pre $none
* @post $none
*/
public List<Double> getAllocatedMipsForVm(Vm
vm) {
return getMipsMap().get(vm.getUid());
}

/**
* Gets the total allocated MIPS for a VM over all
the PEs.
*
* @param vm the vm
* @return the allocated mips for vm
*/
public double getTotalAllocatedMipsForVm(Vm
vm) {
double allocated = 0;
List<Double> mipsMap =
getAllocatedMipsForVm(vm);
if (mipsMap != null) {
for (double mips : mipsMap) {
allocated += mips;
}
}
return allocated;
}

/**
* Returns maximum available MIPS among all the
PEs.
*
* @return max mips
*/
public double getMaxAvailableMips() {
if (getPeList() == null) {
Log.printLine("Pe list is empty");
return 0;
}

double max = 0.0;


for (Pe pe : getPeList()) {
double tmp =
pe.getPeProvisioner().getAvailableMips();
if (tmp > max) {
max = tmp;
}
}

return max;
}

/**
* Returns PE capacity in MIPS.
*
* @return mips
*/
public double getPeCapacity() {
if (getPeList() == null) {
Log.printLine("Pe list is empty");
return 0;
}
return getPeList().get(0).getMips();
}

/**
* Gets the vm list.
*
* @param <T> the generic type
* @return the vm list
*/
@SuppressWarnings("unchecked")
public <T extends Pe> List<T> getPeList() {
return (List<T>) peList;
}

/**
* Sets the vm list.
*
* @param <T> the generic type
* @param peList the pe list
*/
protected <T extends Pe> void setPeList(List<T>
peList) {
this.peList = peList;
}

/**
* Gets the mips map.
*
* @return the mips map
*/
protected Map<String, List<Double>>
getMipsMap() {
return mipsMap;
}

/**
* Sets the mips map.
*
* @param mipsMap the mips map
*/
protected void setMipsMap(Map<String,
List<Double>> mipsMap) {
this.mipsMap = mipsMap;
}

/**
* Gets the free mips.
*
* @return the free mips
*/
public double getAvailableMips() {
return availableMips;
}

/**
* Sets the free mips.
*
* @param availableMips the new free mips
*/
protected void setAvailableMips(double
availableMips) {
this.availableMips = availableMips;
}

/**
* Gets the vms in migration.
*
* @return the vms in migration
*/
public List<String> getVmsMigratingOut() {
return vmsMigratingOut;
}

/**
* Sets the vms in migration.
*
* @param vmsInMigration the new vms migrating
out
*/
protected void setVmsMigratingOut(List<String>
vmsInMigration) {
vmsMigratingOut = vmsInMigration;
}

/**
* Gets the vms migrating in.
*
* @return the vms migrating in
*/
public List<String> getVmsMigratingIn() {
return vmsMigratingIn;
}

/**
* Sets the vms migrating in.
*
* @param vmsMigratingIn the new vms migrating
in
*/
protected void setVmsMigratingIn(List<String>
vmsMigratingIn) {
this.vmsMigratingIn = vmsMigratingIn;
}

/**
* Gets the pe map.
*
* @return the pe map
*/
public Map<String, List<Pe>> getPeMap() {
return peMap;
}

/**
* Sets the pe map.
*
* @param peMap the pe map
*/
protected void setPeMap(Map<String, List<Pe>>
peMap) {
this.peMap = peMap;
}

CloudletScheduler

package org.cloudbus.cloudsim;
import java.util.List;

/**
* CloudletScheduler is an abstract class that represents the
policy of scheduling performed by a
* virtual machine. So, classes extending this must execute
Cloudlets. Also, the interface for
* cloudlet management is also implemented in this class.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
*/
public abstract class CloudletScheduler {

/** The previous time. */


private double previousTime;

/** The current mips share. */


private List<Double> currentMipsShare;
/**
* Creates a new CloudletScheduler object. This
method must be invoked before starting the
* actual simulation.
*
* @pre $none
* @post $none
*/
public CloudletScheduler() {
setPreviousTime(0.0);
}

/**
* Updates the processing of cloudlets running under
management of this scheduler.
*
* @param currentTime current simulation time
* @param mipsShare array with MIPS share of each
processor available to the scheduler
* @return time predicted completion time of the
earliest finishing cloudlet, or 0 if there is no
* next events
* @pre currentTime >= 0
* @post $none
*/
public abstract double updateVmProcessing(double
currentTime, List<Double> mipsShare);

/**
* Receives an cloudlet to be executed in the VM
managed by this scheduler.
*
* @param gl the submited cloudlet
* @param fileTransferTime time required to move
the required files from the SAN to the VM
* @return expected finish time of this cloudlet, or 0
if it is in a waiting queue
* @pre gl != null
* @post $none
*/
public abstract double cloudletSubmit(Cloudlet gl,
double fileTransferTime);

/**
* Receives an cloudlet to be executed in the VM
managed by this scheduler.
*
* @param gl the submited cloudlet
* @return expected finish time of this cloudlet, or 0
if it is in a waiting queue
* @pre gl != null
* @post $none
*/
public abstract double cloudletSubmit(Cloudlet gl);

/**
* Cancels execution of a cloudlet.
*
* @param clId ID of the cloudlet being cancealed
* @return the canceled cloudlet, $null if not found
* @pre $none
* @post $none
*/
public abstract Cloudlet cloudletCancel(int clId);

/**
* Pauses execution of a cloudlet.
*
* @param clId ID of the cloudlet being paused
* @return $true if cloudlet paused, $false otherwise
* @pre $none
* @post $none
*/
public abstract boolean cloudletPause(int clId);

/**
* Resumes execution of a paused cloudlet.
*
* @param clId ID of the cloudlet being resumed
* @return expected finish time of the cloudlet, 0.0 if
queued
* @pre $none
* @post $none
*/
public abstract double cloudletResume(int clId);

/**
* Processes a finished cloudlet.
*
* @param rcl finished cloudlet
* @pre rgl != $null
* @post $none
*/
public abstract void cloudletFinish(ResCloudlet rcl);

/**
* Gets the status of a cloudlet.
*
* @param clId ID of the cloudlet
* @return status of the cloudlet, -1 if cloudlet not
found
* @pre $none
* @post $none
*/
public abstract int getCloudletStatus(int clId);

/**
* Informs about completion of some cloudlet in the
VM managed by this scheduler.
*
* @return $true if there is at least one finished
cloudlet; $false otherwise
* @pre $none
* @post $none
*/
public abstract boolean isFinishedCloudlets();

/**
* Returns the next cloudlet in the finished list, $null
if this list is empty.
*
* @return a finished cloudlet
* @pre $none
* @post $none
*/
public abstract Cloudlet getNextFinishedCloudlet();

/**
* Returns the number of cloudlets runnning in the
virtual machine.
*
* @return number of cloudlets runnning
* @pre $none
* @post $none
*/
public abstract int runningCloudlets();

/**
* Returns one cloudlet to migrate to another vm.
*
* @return one running cloudlet
* @pre $none
* @post $none
*/
public abstract Cloudlet migrateCloudlet();

/**
* Get utilization created by all cloudlets.
*
* @param time the time
* @return total utilization
*/
public abstract double
getTotalUtilizationOfCpu(double time);

/**
* Gets the current requested mips.
*
* @return the current mips
*/
public abstract List<Double>
getCurrentRequestedMips();

/**
* Gets the total current mips for the Cloudlet.
*
* @param rcl the rcl
* @param mipsShare the mips share
* @return the total current mips
*/
public abstract double
getTotalCurrentAvailableMipsForCloudlet(ResCloudlet rcl,
List<Double> mipsShare);

/**
* Gets the total current requested mips for cloudlet.
*
* @param rcl the rcl
* @param time the time
* @return the total current requested mips for
cloudlet
*/
public abstract double
getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl,
double time);

/**
* Gets the total current allocated mips for cloudlet.
*
* @param rcl the rcl
* @param time the time
* @return the total current allocated mips for
cloudlet
*/
public abstract double
getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl,
double time);

/**
* Gets the current requested ram.
*
* @return the current requested ram
*/
public abstract double
getCurrentRequestedUtilizationOfRam();

/**
* Gets the current requested bw.
*
* @return the current requested bw
*/
public abstract double
getCurrentRequestedUtilizationOfBw();

/**
* Gets the previous time.
*
* @return the previous time
*/
public double getPreviousTime() {
return previousTime;
}

/**
* Sets the previous time.
*
* @param previousTime the new previous time
*/
protected void setPreviousTime(double
previousTime) {
this.previousTime = previousTime;
}

/**
* Sets the current mips share.
*
* @param currentMipsShare the new current mips
share
*/
protected void setCurrentMipsShare(List<Double>
currentMipsShare) {
this.currentMipsShare = currentMipsShare;
}

/**
* Gets the current mips share.
*
* @return the current mips share
*/
public List<Double> getCurrentMipsShare() {
return currentMipsShare;
}

Also, Virtual Machine(VM) and Task( Cloudlet) scheduling are one of the most
important and the popular use case to be simulated by researchers using the CloudSim
simulation toolkit.

S-ar putea să vă placă și