CloudSim 里CloudletSchedulerDynamicWorkload类

CloudletSchedulerDynamicWorkload

简介

这个类实现了一个虚拟机用来运行其调度策略,特别适用于假设虚拟机上只有一个Cloudlet作为在线服务运行的情况。

  • 单一Cloudlet假设:这个调度器假设每个虚拟机上只有一个Cloudlet在运行,作为在线服务。这意味着该Cloudlet不需要与其他Cloudlets竞争CPU资源。

  • 扩展时间共享策略:尽管这个调度器扩展了时间共享(TimeShared)策略,但由于假设每个虚拟机上只有一个Cloudlet,实际上该Cloudlet不会与其他Cloudlets竞争CPU时间。这使得调度逻辑相对简单,因为不需要在多个任务之间分配CPU时间。

  • 每个虚拟机的独立实例:与其它Cloudlet调度器一样,每个虚拟机都需要有自己的 CloudletScheduler 实例。这确保了调度策略和状态是针对每个虚拟机独立维护的,从而允许不同的虚拟机根据其特定需求和配置独立地调度其Cloudlets。

  • 这种调度策略适用于那些不需要复杂调度逻辑的场景,特别是当虚拟机主要用于运行单一的、持续的在线服务时。

类属性

VM中每个核心的计算效率

	/** The individual MIPS capacity of each PE allocated to the VM using the scheduler,
         * considering that all PEs have the same capacity. 
         * //TODO Despite of the class considers that all PEs have the same capacity,
         * it accepts a list of PEs with different MIPS at the method 
         * {@link CloudletScheduler#updateCloudletsProcessing(double, List) }
         */
	private double mips;

能够使用的核心数

	/** The number of PEs allocated to the VM using the scheduler. */
	private int numberOfPes;

总核心数

	/** The total MIPS considering all PEs. */
	private double totalMips;

未分配的计算量

	/** The under allocated MIPS. */
	private Map<String, Double> underAllocatedMips;

上一次请求计算能力的大小

	/** The cache of the previous time when the {@link #getCurrentRequestedMips()} was called. */
	private double cachePreviousTime;

最近一次请求计算能力的大小

	/** The cache of the last current requested MIPS. 
         * @see  #getCurrentRequestedMips() 
         */
	private List<Double> cacheCurrentRequestedMips;

实例化一个新的 CloudletSchedulerDynamicWorkload 对象

	/**
	 * Instantiates a new VM scheduler
	 * 
	 * @param mips The individual MIPS capacity of each PE allocated to the VM using the scheduler,
         * considering that all PEs have the same capacity.
	 * @param numberOfPes The number of PEs allocated to the VM using the scheduler.
	 */
	public CloudletSchedulerDynamicWorkload(double mips, int numberOfPes) 

更新运行情况

@Override
	public double updateCloudletsProcessing(double currentTime, List<Double> mipsShare) 

将收到的任务加到控制调度中

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

获得当前每个核心计算能力的需求量

	@Override
	public List<Double> getCurrentRequestedMips() 

获得当前总计算能力的需求量

@Override
	public double getCurrentRequestedTotalMips()

返回当前任务下可以用的CPU计算能力

	// Simple policy, there is no real scheduling involved
	@Override
	public double getTotalCurrentAvailableMipsForCloudlet(Cloudlet cl, List<Double> mipsShare) {
		return getCurrentCapacity() * cl.getNumberOfPes();
	}

返回当前任务下已经使用的的CPU计算能力

	@Override
	public double getTotalCurrentAllocatedMipsForCloudlet(Cloudlet cl, double time) {
		return getTotalCurrentAvailableMipsForCloudlet(cl, getCurrentMipsShare());
	}

返回当前任务下CPU计算能力的需求量

	@Override
	public double getTotalCurrentRequestedMipsForCloudlet(Cloudlet cl, double time) {
		return getTotalCurrentAvailableMipsForCloudlet(cl, getCurrentMipsShare());
	}

更新未分配的计算量

	/**
	 * Update under allocated mips for cloudlet.
	 * 
	 * @param cl the cloudlet
	 * @param mips the mips
         * //TODO It is not clear the goal of this method. The related test case
         * doesn't make it clear too. The method doesn't appear to be used anywhere.
	 */
	public void updateUnderAllocatedMipsForCloudlet(Cloudlet cl, double mips)

获得预估的完成时间

	/**
	 * Get the estimated completion time of a given cloudlet.
	 * 
	 * @param cl the cloudlet
	 * @param time the time
	 * @return the estimated finish time
	 */
	@Override
	public double getEstimatedFinishTime(Cloudlet cl, double time)
/**
	 * Gets the total current mips available for the VM using the scheduler.
         * The total is computed from the {@link #getCurrentMipsShare()}
	 * 
	 * @return the total current mips
	 */
	public double getTotalCurrentMips()

获得VM的当前总计算能力

/**
	 * Gets the total current mips available for the VM using the scheduler.
         * The total is computed from the {@link #getCurrentMipsShare()}
	 * 
	 * @return the total current mips
	 */
	public double getTotalCurrentMips()

设置总计算能力

	/**
	 * Sets the total mips.
	 * 
	 * @param mips the new total mips
	 */
	public void setTotalMips(double mips)

获得总计算能力

	/**
	 * Gets the total mips.
	 * 
	 * @return the total mips
	 */
	public double getTotalMips()

设置核心数量

	/**
	 * Sets the pes number.
	 * 
	 * @param pesNumber the new pes number
	 */
	public void setNumberOfPes(int pesNumber)

获得总核心数量

	/**
	 * Gets the pes number.
	 * 
	 * @return the pes number
	 */
	public int getNumberOfPes()

设置单个核心的计算频率

	/**
	 * Sets the mips.
	 * 
	 * @param mips the new mips
	 */
	public void setMips(double mips)

获得单个核心的计算频率

	/**
	 * Gets the mips.
	 * 
	 * @return the mips
	 */
	public double getMips()

设置未分配的计算能力

	/**
	 * Sets the under allocated mips.
	 * 
	 * @param underAllocatedMips the under allocated mips
	 */
	public void setUnderAllocatedMips(Map<String, Double> underAllocatedMips)

获得未分配的计算能力

	/**
	 * Gets the under allocated mips.
	 * 
	 * @return the under allocated mips
	 */
	public Map<String, Double> getUnderAllocatedMips()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值