How we can create Vm with different number of MIPS in cloudsim?

629 Views Asked by At

i create 10 vm by using loop.and every Vm use same number of MIPS , as the parameter for all the Vms are same .how i can create differnt vms with different mips?

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

    //create VMs
    CondorVM[] vm = new CondorVM[vms];

    for (int i = 0; i < vms; i++) {
        double ratio = 1.0;
        vm[i] = new CondorVM(i, userId, mips * ratio, pesNumber, ram, bw, size, vmm, new CloudletSchedulerSpaceShared());
        list.add(vm[i]);
    }

    return list;
}

in the main method vmNum is initialized is equal to 10.

1

There are 1 best solutions below

4
Chanda Korat On

Simple is that. Create an array of mips and pass it to vm constructor over a loop.

In your example:

long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int[] mips= {1000,200,3000,.....,500}; //Here's the array
long bw = 1000;
    int pesNumber = 1; //number of cpus
    String vmm = "Xen"; //VMM name

    //create VMs
    CondorVM[] vm = new CondorVM[vms];

    for (int i = 0; i < vms; i++) {
        double ratio = 1.0;
        vm[i] = new CondorVM(i, userId, mips[i] * ratio, pesNumber, ram, bw, size, vmm, new CloudletSchedulerSpaceShared());
        list.add(vm[i]);
    }

    return list;
}

Hope it would help you !!