How to do Virtual machine and Task Scheduling in CloudSim

This article will help you 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

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.

Note: In cloudsim, the task is called as cloudlet, therefore in the following text instead of ‘task’ we will be using the ‘cloudlet’.

Cloudsim Virtual Machine Scheduling

The VmScheduler is an abstract class that defines and implements the policy used to share processing power among virtual machines running on a specified host. The hierarchy of the cloudsim virtual machine scheduler classes is as:

VmScheduler Class Hierarchy for virtual machine scheduling in cloudsim
Cloudsim Virtual Machine Scheduler Class Hierarchy

These classes can be located in “org.cloudbus.cloudsim” package of cloudsim. The definition of this abstract class is extended to the following types of policies implemented as classes:

  • VmSchedulerTimeShared: This class implements the VM scheduling policy that allocates one or more processing elements to a single Virtual machine and allows the sharing of processing elements by multiple virtual machines with a specified time slice. This class also considers the overhead of VM allocation switching(similar to context switching) in policy definition. Here, the VM allocation will fail if the number of processing elements requested is not available. for example, if the VM request for quad-core processor whereas the allocated host has an only dual-core the allocation will fail.
  • VmSchedulerSpaceShared: This class implements the VM scheduling policy that allocates one or more processing elements to a single virtual machine, but this policy implementation does not support sharing of processing elements (i.e.) all the requested resources will be used by the allocated VM till the time the VM is not destroyed. Also, Under this allocation policy, if any virtual machine requests a processing element and is not available at that time, the allocation fails.
  • VmSchedulerTimeSharedOverSubscription: This is an extended implementation of VMSchedulerTimeShared VM scheduling policy, which allows over-subscription of processing elements by the virtual machine(s) (i.e.) the scheduler still allows the allocation of VMs that require more CPU capacity that is available. And this oversubscription results in performance degradation.

The application of the VmScheduler classes is while instantiating the host model. Following is the code snippet used in from line number 160 to 174:

int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;

	        new Host(
		new RamProvisionerSimple(ram),
		new BwProvisionerSimple(bw),
		new VmSchedulerTimeShared(peList)
); // This is our machine

This is where the processing element list is passed as a parameter to the VmSchedulerTimeShared() class call and during the simulation, the cloudsim will simulate the timeshare behavior for the virtual machines. Also, in case you want to test other VmScheduler you may replace it with VmSchedulerTimeShared() call with appropriate parameters, this includes your own designed custom virtual machine scheduler.

Cloudsim Cloudlet Scheduling

The “CloudletScheduleris an abstract class that defines the basic skeleton to implement the policy to be used for cloudlet scheduling to be performed by a virtual machine. The hierarchy of the cloudsim Cloudlet scheduler classes is as:

Cloudlet Scheduler Class Hierarchy for Task Scheduling in cloudsim
Cloudlet Scheduler Class Hierarchy

These classes again exist in “org.cloudbus.cloudsim” package of cloudsim. The definition of this abstract class is extended as the following types of policies implemented as three individual classes in cloudsim:

  • CloudletSchedulerSpaceShared: This class implements a policy of scheduling for Virtual machine to execute cloudlet(s) in space shared environment (i.e.) only one cloudlet will be executed on a virtual machine at a time. It means cloudlets share the same queue and requests are processed one at a time per computing core. Space-sharing is similar to batch processing.
  • CloudletSchedulerTimeShared: This class implements a policy of cloudlet scheduling for Virtual machines to execute cloudlets in a time-shared environment (i.e.) more than one cloudlet will be submitted to the virtual machine and each will get its specified share of time. It means several requests (cloudlets) are processed at once but they must share the computing power of that virtual machine(by simulating context switching), so they will affect each other’s processing time. It basically influences the completion time of a cloudlet in CloudSim. Time-sharing is probably referring to the concept of sharing executing power (such as CPU, logical processor, GPU) and is commonly known as the round-robin scheduling.
  • CloudletSchedulerDynamicWorkload: This implements a special policy of scheduling for virtual machine assuming that there is just one cloudlet which is working as an online service with a different requirement of workload as per the need of peak/offpeak user load at a specified period of time.

The application of the CloudletScheduler classes is while instantiating the Vm model. Following is the code snippet used in from line number 82 to 91:

int vmid = 0;
int mips = 1000;
long size = 10000; // image size (MB)
int ram = 512; // vm memory (MB)
long bw = 1000;
int pesNumber = 1; // number of cpus
String vmm = "Xen"; // VMM name

Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared()); // create VM

By instantiating the CloudletSchedulerTimeShared() class, the Virtual machine is decided to follow the timeshare(round-robin) approach while simulation for scheduling & executing the Cloudlets. Also, in case you want to test other CloudletScheduler you may replace it with CloudletSchedulerTimeShared() call with appropriate parameters, this includes your own designed custom cloudlet scheduler.

Now in case you want to implement your own scheduling policies with respect to Virtual Machine or Cloudlet(s), you may simply extend the VmScheduler or CloudletScheduler class to implement all the abstract methods as specified. This gives you the flexibility to design and implement your own set of algorithms and then later test & optimize during the repetitive simulation runs.

Learn More

In case you missed reading our popular article on Detailed introduction to Cloudsim you may follow CloudSim Simulation Toolkit: An Introduction.

You may subscribe to an online self-paced course named Learn Basics of Cloudsim, The content for this course which will be updated weekly till August 2021.

CloudSim Setup using Eclipse

“How to install Cloudsim?” or “How to setup Cloudsim?” is the first question that comes to your mind when you come to know about it. And, when you look at the various links and forums, Does it looks a bit tricky?

DO NOT WORRY, the Cloudsim simulation toolkit setup or you can say the installation of cloudsim is very easy. This Cloudsim tutorial is going to take through the steps by step journey.

Now before you start to setup CloudSim, following resources must be Installed/downloaded on the local system

Cloudsim simulation toolkit setup is easy. Before you start to setup CloudSim, following resources must be Installed/downloaded on the local system

  • Java Development Kit(JDK): As the Cloudsim simulation toolkit is a class library written in the Java programming language, therefore, the latest version of Java(JDK) should be installed on your machine, which can be downloaded from Oracles Java portal. For assistance in the installation process, detailed documentation is provided by Oracle itself and you may follow the installation instructions
  • Eclipse IDE for Java developers: As per your current installed operating system(Linux/Windows). Before you download to make sure to check if 32-bit or 64-bit version is applicable to your Computer machine. Link for Eclipse Kepler version is available at the following link
  • Download CloudSim source code: To date, various versions of CloudSim are released the latest version is 5.0, which is based on a container-based engine. Whereas to keep the setup simple for beginners we will be setting up the most used version i.e. 3.0.3, which can be directly downloaded by clicking on any of the following: Click for Windows or click for Linux.
  • One external requirement of Cloudsim i.e. common jar package of math-related functions is to be downloaded from the Apache website or you may directly download by clicking here.
  • Unzip Eclipse, Cloudsim and Common Math libraries to some common folder.
Note: Installation steps are almost similar for Windows as well as Linux computer system. 

Let’s Get Started to answer “How to install Cloudsim?”

First of all, navigate to the folder where you have unzipped the eclipse folder and open Eclipse.exe


Now within Eclipse window navigate the menu: File -> New -> Project, to open the new project wizard


A ‘New Project‘ wizard should open. There are a number of options displayed and you have to find & select the ‘Java Project‘ option, once done click ‘Next


Now a detailed new project window will open, here you will provide the project name and the path of CloudSim project source code, which will be done as follows:

  • Project Name: CloudSim.
  • Unselect the ‘Use default location’ option and then click on ‘Browse’ to open the path where you have unzipped the Cloudsim project and finally click Next to set project settings.

Make sure you navigate the path till you can see the bin, docs, examples etc folder in the navigation plane.

Step 6

Once done finally, click ‘Next’ to go to the next step i.e. setting up of project settings


Now open ‘Libraries’ tab and if you do not find commons-math3-3.x.jar (here ‘x’ means the minor version release of the library which could be 2 or greater) in the list then simply click on Add External Jar’ (commons-math3-3.x.jar will be included in the project from this step)

Step 8

Once you have clicked on ‘Add External JAR’s‘ Open the path where you have unzipped the commons-math binaries and select ‘Commons-math3-3.x.jar’ and click on open.


Ensure external jar that you opened in the previous step is displayed in the list and then click on ‘Finish’ (your system may take 2-3 minutes to configure the project)


Once the project is configured you can open the ‘Project Explorerand start exploring the Cloudsim project. Also for the first time eclipse automatically start building the workspace for newly configured Cloudsim project, which may take some time depending on the configuration of the computer system.

Following is the final screen which you will see after Cloudsim is configured.

Step 11

Now just to check you within the ‘Project Explorer‘, you should navigate to the ‘examples‘ folder, then expand the package ‘org.cloudbus.cloudsim.examples‘ and double click to open the ‘‘.

Step 12 1

Now navigate to the Eclipse menu ‘Run -> Run‘ or directly use a keyboard shortcut ‘Ctrl + F11’ to execute the ‘‘.


if it is successfully executed it should be displaying the following type to output in the console window of the Eclipse IDE.


If Yes then Congratulations!! Now you have successfully setup/Installed the CloudSim Simulation Toolkit on your computer machine and you are ready to start with the experimentation for your further research work. For more insight into the class hierarchy, you may refer to “CloudSim Simulation Toolkit: An Introduction“. Also, You may subscribe to an online self-paced course named Learn Basics of Cloudsim, The content for this course which will be updated weekly till August 2021. Click here to get the applicable discount coupon codes.

Did you encounter an error during the setup of cloudsim?

If you have encountered some error then the eclipse may look like this:

Most of the times, the type of error that you may encounter during setting up of the cloudsim in eclipse should be stating either:
“Syntax error, parameterized types are only available if source level is 1.5 or greater.”

Cloudsim Setup Error Type 1


“Syntax error ‘for each’ statements are only available if source level is 1.5 or greater.”

Cloudsim Setup Error Type 2

These errors occur due to two reasons:
Case 1: The version of Java installed on your computer system is older than 1.5
Case 2: Your default java environment for the eclipse project not set to the latest java version which is available on your computer system.

For Case 1, you have to download and install the latest java version from Oracle/Java website.

For Case 2, you have to do some modifications in the eclipse project, and for this, you should follow these steps:

  1. In the eclipse IDE menu, click on ‘Project’ and from the dropped menu list click on ‘Properties’ to open a project properties window.
  2. On the project properties window, from the list available on left select ‘Java Compiler’, this will display the compiler options.
  3. Now, click on the ‘Enable Project Specific Settings’ checkbox, which further enables the options provided just below the checkbox.
  4. Now, under JDK compliance heading change the ‘Compiler Compliance Level’ to the highest number available on the list.
  5. Also, make sure “Use default compliance settings” should be in the checked state.
  6. Now, click on the “Apply and Close” button. Now a popup alert will be displayed asking for the confirmation to apply the settings. Click ‘Yes’.

Now you will notice that the rebuild process for the project will get started and to confirm the error is resolved or not. You may check the error log window or run any example class available in org.cloudbus.cloudsim.examples namespace.

You may also follow the detailed step by step demo to “Configure CloudSim using Eclipse IDE

Hope this article helped you answer your big question on “How to install Cloudsim using Eclipse?

In case you find this article suitable for your work or you find any difficulty in following the method mentioned above you may feel free to share in the comments section.