From: <mar...@us...> - 2008-02-11 06:09:48
|
Revision: 98 http://gridsim.svn.sourceforge.net/gridsim/?rev=98&view=rev Author: marcos_dias Date: 2008-02-10 22:09:53 -0800 (Sun, 10 Feb 2008) Log Message: ----------- This update contains small bug fixes and improvements: + The advance reservation policy and the conservative backfilling could present overlapping ranges of available processing elements. Although that did not affect the resource allocation results, that could lead to infinite loops on software that queried the resource availability. + Small changes in the availability information objects and the lists of PEs. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/util/SimReport.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-11 05:28:07 UTC (rev 97) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-11 06:09:53 UTC (rev 98) @@ -261,10 +261,7 @@ Sim_event ev = new Sim_event(); while ( Sim_system.running() ) { super.sim_get_next(ev); - if (ev.get_src() == super.myId_) - processEvent(ev); - else - processOtherEvent(ev); + processEvent(ev); } // CHECK for ANY INTERNAL EVENTS WAITING TO BE PROCESSED @@ -1577,12 +1574,6 @@ } } resource_.setPEsAvailable(releasedRanges); - -// if(PERangeList.containsOverlappingRanges(resource_.getFreePERanges())) { -// System.out.println("Overlap! Ranges = " + resource_.getFreePERanges()); -// System.exit(1); -// } - itemsStarted = startReservation(currentTime); // remove past entries from the availability profile @@ -1715,12 +1706,6 @@ while(iterProfile.hasNext()) { AvailabilityProfileEntry entry = iterProfile.next(); -// if(PERangeList.containsOverlappingRanges(entry.getPERanges())) { -// System.out.println(" Profile entry at time " + entry.getTime() + -// " contains overlapping ranges. Ranges = " + entry.getPERanges()); -// System.exit(0); -// } - if(entry.getTime() <= referenceTime){ iterProfile.remove(); } @@ -1976,7 +1961,6 @@ result[2] = super.selectPERangeList(reqPE, intersectList); return result; } - /** * Selects a list of PE ranges able to provide enough PEs @@ -2147,9 +2131,7 @@ // Update entries of the profile for(int index=0; index<tailIndex; index++) { AvailabilityProfileEntry entry = availProfile_.get(index); -// if(entry.getTime() < startTime){ -// continue; -// } + PERangeList uptList = PERangeList.difference(entry.getPERanges(), selected); entry.setPERangeList(uptList); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-11 05:28:07 UTC (rev 97) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-11 06:09:53 UTC (rev 98) @@ -101,19 +101,19 @@ public class CBParallelSpaceShared extends TAllocPolicy { // Queue of waiting Gridlets - private LinkedList<SSGridlet> queuedGridlets_; + protected LinkedList<SSGridlet> queuedGridlets_; // Queue of running Gridlets - private LinkedList<SSGridlet> runningGridlets_; + protected LinkedList<SSGridlet> runningGridlets_; - // The rating of one PE - private int ratingPE_; - // a list containing the availability of PEs - private AvailabilityProfile availProfile_; + protected AvailabilityProfile availProfile_; // the resource characteristics object to be used - private TResourceCharacteristics resource_; + protected TResourceCharacteristics resource_; + + // The rating of one PE + private int ratingPE_; // to order gridlets by potential start time private OrderGridletByStartTime orderStartTime_; @@ -170,28 +170,16 @@ ratingPE_ = resource_.getMIPSRatingOfOnePE(); // a loop that is looking for internal events only + // This loop does not stop when the policy receives an + // end of simulation event because it needs to handle + // all the internal events before it finishes its + // execution. This is important particularly for the + // graphical user interface to show the completion of + // advance reservations Sim_event ev = new Sim_event(); while ( Sim_system.running() ) { super.sim_get_next(ev); - - // if the simulation finishes then exit the loop - if (ev.get_tag() == GridSimTags.END_OF_SIMULATION || - super.isEndSimulation() == true) { - break; - } - - // Internal Event if the event source is this entity - if (ev.get_src() == super.myId_ && - ev.get_tag() == GRIDLET_FINISHED) { - double currentTime = GridSim.clock(); - if(currentTime > lastScheduleUpdate_) { - updateSchedule(); - } - lastScheduleUpdate_ = currentTime; - } - else { - processOtherEvent(ev); - } + processEvent(ev); } // CHECK for ANY INTERNAL EVENTS WAITING TO BE PROCESSED @@ -207,7 +195,7 @@ orderStartTime_ = null; availProfile_.clear(); } - + /** * Schedules a new <tt>Gridlet</tt> received by the * <tt>GridResource</tt> entity. @@ -472,6 +460,31 @@ } // -------------------- PRIVATE METHODS ---------------------------- + + /** + * Process and event sent to this entity + * @param ev the event to be handled + */ + private void processEvent(Sim_event ev) { + + // handle an internal event + double currentTime = GridSim.clock(); + + switch(ev.get_tag()) { + // time to update the schedule, finish gridlets, + // finish reservations, start reservations and start gridlets + case GRIDLET_FINISHED: + if(currentTime > lastScheduleUpdate_) { + updateSchedule(); + } + lastScheduleUpdate_ = currentTime; + break; + + default: + processOtherEvent(ev); + break; + } + } /** * Allocates a Gridlet into free PEs, sets the Gridlet status to INEXEC, Modified: branches/gridsim4.0-branch3/source/gridsim/util/SimReport.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/util/SimReport.java 2008-02-11 05:28:07 UTC (rev 97) +++ branches/gridsim4.0-branch3/source/gridsim/util/SimReport.java 2008-02-11 06:09:53 UTC (rev 98) @@ -124,7 +124,7 @@ * @pre $none * @post $none */ - public void write(int num, String desc) + public synchronized void write(int num, String desc) { buffer_.append( GridSim.clock() ); buffer_.append(indent_); @@ -144,7 +144,7 @@ * @pre $none * @post $none */ - public void write(double num, String desc) + public synchronized void write(double num, String desc) { buffer_.append( GridSim.clock() ); buffer_.append(indent_); @@ -164,7 +164,7 @@ * @pre $none * @post $none */ - public void write(long num, String desc) + public synchronized void write(long num, String desc) { buffer_.append( GridSim.clock() ); buffer_.append(indent_); @@ -183,7 +183,7 @@ * @pre $none * @post $none */ - public void write(String data) + public synchronized void write(String data) { buffer_.append( GridSim.clock() ); buffer_.append(indent_); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |