云计算仿真工具中文注释CloudletSchedulerSpaceShared.java

/*
 * Title:        CloudSim Toolkit
 * Description:  CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 *
 * Copyright (c) 2009-2010, The University of Melbourne, Australia
 */

package org.cloudbus.cloudsim;

import java.util.ArrayList;
import java.util.List;

import org.cloudbus.cloudsim.core.CloudSim;

/**
 * cloudletschedulerspaceshared实现了vm对于cloudlet的一个调度策略
 * 
 * CloudletSchedulerSpaceShared implements a policy of
 * scheduling performed by a virtual machine. It consider
 * that there will be only one cloudlet per VM. Other cloudlets will be in a
 * waiting list. We consider that file transfer from cloudlets waiting happens
 * before cloudlet execution. I.e., even though cloudlets must wait for CPU,
 * data transfer happens as soon as cloudlets are submitted.
 *
 * @author		Rodrigo N. Calheiros
 * @author		Anton Beloglazov
 * @since		CloudSim Toolkit 1.0
 */
public class CloudletSchedulerSpaceShared extends CloudletScheduler {

	/** The cloudlet waiting list. */
	private List<? extends ResCloudlet> cloudletWaitingList;

	/** The cloudlet exec list. */
	private List<? extends ResCloudlet> cloudletExecList;

	/** The cloudlet paused list. */
	private List<? extends ResCloudlet> cloudletPausedList;

	/** The cloudlet finished list. */
	private List<? extends ResCloudlet> cloudletFinishedList;

	/** The current CPUs. */
	protected int currentCpus;

	/** The used PEs. */
	protected int usedPes;

	/**
	 * Creates a new CloudletSchedulerSpaceShared object. This method must be invoked
	 * before starting the actual simulation.
	 *
	 * @pre $none
	 * @post $none
	 */
	public CloudletSchedulerSpaceShared() {
		//父类字段:previoustime和currentmipshare
		super();
		this.cloudletWaitingList = new ArrayList<ResCloudlet>();
		this.cloudletExecList = new ArrayList<ResCloudlet>();
		this.cloudletPausedList = new ArrayList<ResCloudlet>();
		this.cloudletFinishedList = new ArrayList<ResCloudlet>();
		this.usedPes = 0;
		this.currentCpus = 0;
	}

	/**
	 * 当前时间,更新cloudlet状态,当有任务完成时,加入新的任务,返回下一个任务完成的时刻
	 * 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
	 *        每个cpu提供的计算能力
	 * @return time predicted completion time of the earliest finishing cloudlet, or 0
	 * if there is no next events
	 *
	 * @pre currentTime >= 0
	 * @post $none
	 */
	@Override
	public double updateVmProcessing(double currentTime, List<Double> mipsShare) {
		setCurrentMipsShare(mipsShare);
		double timeSpam = currentTime - getPreviousTime(); // time since last update
		double capacity = 0.0;
		int cpus = 0;

		for (Double mips : mipsShare) { // count the CPUs available to the VMM
			capacity += mips;
			if (mips > 0) {
				cpus++;
			}
		}
		currentCpus = cpus;
		capacity /= cpus; // average capacity of each cpu

		for (ResCloudlet rcl : getCloudletExecList()) { // cpu个数等于任务在exec队列中乘以pe个数each machine in the exec list has the same amount of cpu
			rcl.updateCloudletFinishedSoFar((long) (capacity * timeSpam * rcl.getPesNumber()));
		}

		if (getCloudletExecList().size() == 0 && getCloudletWaitingList().size() == 0) { // no more cloudlets in this scheduler
			setPreviousTime(currentTime);             //所有任务执行完毕,设置此时刻
			return 0.0;
		}

		//update each cloudlet
		int finished = 0;
		int cont = 0;
		List<ResCloudlet> toRemove = new ArrayList<ResCloudlet>();
		for (ResCloudlet rcl : getCloudletExecList()) {
			if (rcl.getRemainingCloudletLength() == 0.0) {// finished anyway, rounding issue...
				toRemove.add(rcl);
				clo
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值