⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resourcecharacteristics.java

📁 一个非常著名的网格模拟器,能够运行网格调度算法!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @post $result >= -1     */    public int getMIPSRatingOfOnePE()    {        if (machineList_.size() == 0) {            return -1;        }        return machineList_.getMachine(0).getPEList().getMIPSRating(0);    }    /**     * Gets Millions Instructions Per Second (MIPS) Rating of a Processing     * Element (PE).     * It is essential to use this method when a resource is made up     * of heterogenous PEs/machines.     * @param id    the machine ID     * @param peID  the PE ID     * @return the MIPS Rating or <tt>-1</tt> if no PEs are exists.     * @deprecated As of GridSim 2.1, replaced by     *             {@link #getMIPSRatingOfOnePE(int, int)}     * @pre id >= 0     * @pre peID >= 0     * @post $result >= -1     */    public int GetMIPSRatingOfOnePE(int id, int peID) {        return this.getMIPSRatingOfOnePE(id, peID);    }    /**     * Gets Millions Instructions Per Second (MIPS) Rating of a Processing     * Element (PE).     * It is essential to use this method when a resource is made up     * of heterogenous PEs/machines.     * @param id        the machine ID     * @param peID      the PE ID     * @return the MIPS Rating or <tt>-1</tt> if no PEs are exists.     * @pre id >= 0     * @pre peID >= 0     * @post $result >= -1     */    public int getMIPSRatingOfOnePE(int id, int peID)    {        if (machineList_.size() == 0) {            return -1;        }        return machineList_.getMachine(id).getPEList().getMIPSRating(peID);    }    /**     * Gets the total MIPS rating, which is the sum of MIPS rating of all     * machines in a resource     * @return the sum of MIPS ratings     * @deprecated As of GridSim 2.1, replaced by {@link #getMIPSRating()}     * @pre $none     * @post $result >= 0     */    public int GetMIPSRating() {        return this.getMIPSRating();    }    /**     * Gets the total MIPS rating, which is the sum of MIPS rating of all     * machines in a resource.     * <p>     * Total MIPS rating for:     * <ul>     *     <li>TimeShared = 1 Rating of a PE * Total number of PEs     *     <li>Other policy same rating = same as TimeShared     *     <li>SpaceShared = Sum of all PEs in all Machines     *     <li>Other policy different rating = same as SpaceShared     *     <li>Advance Reservation = 0 or unknown.     *         You need to calculate this manually.     * </ul>     *     * @return the sum of MIPS ratings     * @pre $none     * @post $result >= 0     */    public int getMIPSRating()    {        int rating = 0;        switch (allocationPolicy_)        {            // Assuming all PEs in all Machine have same rating.            case ResourceCharacteristics.TIME_SHARED:            case ResourceCharacteristics.OTHER_POLICY_SAME_RATING:                rating = getMIPSRatingOfOnePE() * machineList_.getNumPE();                break;            // Assuming all PEs in a given Machine have the same rating.            // But different machines in a Cluster can have different rating            case ResourceCharacteristics.SPACE_SHARED:            case ResourceCharacteristics.OTHER_POLICY_DIFFERENT_RATING:                for (int i = 0; i < machineList_.size(); i++) {                    rating += ((Machine) machineList_.get(i)).getMIPSRating();                }                break;            default:                break;        }        return rating;    }    /**     * Gets the CPU time given the specified parameters     * @param gridletLength     the length of a Gridlet     * @param load              the load of a Gridlet     * @return the CPU time     * @deprecated As of GridSim 2.1, replaced by     *             {@link #getCPUTime(double, double)}     * @pre gridletLength >= 0.0     * @pre load >= 0.0     * @post $result >= 0.0     */    public double CPU_time(double gridletLength, double load) {        return this.getCPUTime(gridletLength, load);    }    /**     * Gets the CPU time given the specified parameters (only for TIME_SHARED).     * <tt>NOTE:</tt> The CPU time for SPACE_SHARED and ADVANCE_RESERVATION     *                are not yet implemented.     * @param gridletLength     the length of a Gridlet     * @param load              the load of a Gridlet     * @return the CPU time     * @pre gridletLength >= 0.0     * @pre load >= 0.0     * @post $result >= 0.0     */    public double getCPUTime(double gridletLength, double load)    {        double cpuTime = 0.0;        switch (allocationPolicy_)        {            case ResourceCharacteristics.TIME_SHARED:                cpuTime = gridletLength / ( getMIPSRatingOfOnePE()*(1.0-load) );                break;            default:                break;        }        return cpuTime;    }    /**     * Gets the total number of PEs for all Machines     * @return number of PEs     * @deprecated As of GridSim 2.1, replaced by {@link #getNumPE()}     * @pre $none     * @post $result >= 0     */    public int GetNoOfPEs() {        return this.getNumPE();    }    /**     * Gets the total number of PEs for all Machines     * @return number of PEs     * @pre $none     * @post $result >= 0     */    public int getNumPE() {        return machineList_.getNumPE();    }    /**     * Gets the total number of <tt>FREE</tt> or non-busy PEs for all Machines     * @return number of PEs     * @pre $none     * @post $result >= 0     */    public int getNumFreePE() {        return machineList_.getNumFreePE();    }    /**     * Gets the total number of <tt>BUSY</tt> PEs for all Machines     * @return number of PEs     * @pre $none     * @post $result >= 0     */    public int getNumBusyPE() {        return machineList_.getNumBusyPE();    }    /**     * Sets the particular PE status on a Machine     * @param status   PE status, either <tt>PE.FREE</tt> or <tt>PE.BUSY</tt>     * @param machineID    Machine ID     * @param peID     PE id     * @return <tt>true</tt> if the PE status has changed, <tt>false</tt>     * otherwise (Machine id or PE id might not be exist)     * @pre machineID >= 0     * @pre peID >= 0     * @post $none     */    public boolean setStatusPE(boolean status, int machineID, int peID) {        return machineList_.setStatusPE(status, machineID, peID);    }    /**     * Sets the cost per second associated with a resource     * @param costPerSec   the cost using a resource     * @deprecated As of GridSim 2.1, replaced by {@link #setCostPerSec(double)}     * @pre costPerSec >= 0.0     * @post $none     */    public void SetCostPerSec(double costPerSec) {        this.setCostPerSec(costPerSec);    }    /**     * Sets the cost per second associated with a resource     * @param costPerSec   the cost using a resource     * @pre costPerSec >= 0.0     * @post $none     */    public void setCostPerSec(double costPerSec) {        this.costPerSec_ = costPerSec;    }    /**     * Gets the cost per second associated with a resource     * @return the cost using a resource     * @deprecated As of GridSim 2.1, replaced by {@link #getCostPerSec()}     * @pre $none     * @post $result >= 0.0     */    public double GetCostPerSec() {        return this.getCostPerSec();    }    /**     * Gets the cost per second associated with a resource     * @return the cost using a resource     * @pre $none     * @post $result >= 0.0     */    public double getCostPerSec() {        return costPerSec_;    }    /**     * Gets the cost per Millions Instruction (MI) associated with a resource     * @return the cost using a resource     * @deprecated As of GridSim 2.1, replaced by {@link #getCostPerMI()}     * @pre $none     * @post $result >= 0.0     */    public double GetCostPerMI() {        return this.getCostPerMI();    }    /**     * Gets the cost per Millions Instruction (MI) associated with a resource     * @return the cost using a resource     * @pre $none     * @post $result >= 0.0     */    public double getCostPerMI() {        return costPerSec_ / getMIPSRatingOfOnePE();    }    /**     * Gets the byte size of this class     * @return the byte size     * @deprecated As of GridSim 2.1, replaced by {@link #getByteSize()}     * @pre $none     * @post $result > 0     */    public int ByteSize() {        return this.getByteSize();    }    /**     * Gets the byte size of this class     * @return the byte size     * @pre $none     * @post $result > 0     */    public int getByteSize()    {        // this class overall has: 2 ints, 2 Strings, 1 MachineList and        //                         2 doubles.        // NOTE: static attributes do not count        int totalInt = 2 * 4;        int totalDouble = 2 * 8;        int totalSize = architecture_.length() + OS_.length() +                   machineList_.getByteSize() + totalInt + totalDouble ;        return totalSize;    }} // end class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -