protected int backfillGridlets() {
    	int gridletStarted = 0;
    	
    	// checks the pivot first
	    if(pivot != null && pivot.getStartTime() <= GridSim.clock()) {
	    	gridletStarted++;
	    	waitingJobs.remove(pivot);  // pivots should be at the beginning anyway
	    	runningJobs.add(pivot);
	    	
    	    pivot.setStatus(Gridlet.INEXEC);
    	    super.sendInternalEvent(pivot.getActualFinishTime()-GridSim.clock(), UPT_SCHEDULE);
	    	pivot = null;
	    		
	        //-------------- FOR DEBUGGING PURPOSES ONLY  --------------
	        visualizer.notifyListeners(super.get_id(), ActionType.SCHEDULE_CHANGED, true);
	        //----------------------------------------------------------
    	}
    	
    	if(jobOrder != null) {
    		Collections.sort(waitingJobs, jobOrder);
    	}
    	    	
    	// Start the execution of jobs that are queued
    	Iterator<SSGridlet >iter = waitingJobs.iterator();
		while (iter.hasNext()) {
			SSGridlet gridlet = iter.next();
			
			// required to skip pivot
			if(gridlet == this.pivot) {
				continue;
			}
			
    		boolean success = startGridlet(gridlet);
    	    if(success) {
    	    	iter.remove();
        		gridletStarted++;
    	    } else { 
    	    	success = scheduleGridlet(gridlet);
    	    }

        	//-------------- FOR DEBUGGING PURPOSES ONLY  --------------
	    	if(success) {
            	visualizer.notifyListeners(super.get_id(), 
            			ActionType.ITEM_SCHEDULED, true, gridlet);
	    	}
            //----------------------------------------------------------
    	}
		
		// updates list of free resources available 
		// (hack to be compatible with GridSim's way of maintaining availability) 
		dynamics.resetFreePERanges(profile.checkImmediateAvailability().getAvailRanges());
    	return gridletStarted;
    }