コード例 #1
0
  public Job nextStep(int simulationTime) {

    updateReadyQueue(simulationTime);
    if (simulationTime != 0 && currentJob.getRemainTime() != 0) {
      readyQueue.addJob(currentJob);
    }
    if (readyQueue.size() > 1) {
      readyQueue.OrderedByPriority();
    }
    if (readyQueue.isEmpty()) {
      return null;
    }
    setCurrentJob();
    return workInCPU(simulationTime);
  }
コード例 #2
0
 /**
  * Show queue content (every job details) improved version of toString method but used for
  * testing.
  *
  * @param list Queue to show it's content
  */
 public void showQueue(int simulationTime) {
   if (mainList.isEmpty()) {
     System.out.println("Empty Queue");
     return;
   } // if queue is empty
   System.out.println("number of jobs " + mainList.size());
   System.out.println(
       "# "
           + " Arrive "
           + " Burst "
           + " Priority "
           + " Start "
           + " Wait "
           + " Remain "
           + " Finish "
           + " Turn "
           + " % ");
   for (int i = 0; i < mainList.size(); i++) // show every job data
   {
     Job temp = mainList.get(i);
     System.out.print(
         temp.jobNumber + "    " + temp.arrivalTime + "      " + temp.burst + "       ");
     System.out.print(
         temp.priority
             + "      "
             + temp.getStart()
             + "      "
             + temp.getWaitTime(simulationTime)
             + "      ");
     System.out.print(
         temp.getRemainTime()
             + "       "
             + temp.getFinish()
             + "      "
             + temp.getTurnaround(simulationTime)
             + "    ");
     System.out.println(temp.getPercent());
   }
 }
コード例 #3
0
 public boolean isFinished() {
   return (list.isEmpty() && readyQueue.isEmpty() && !busy && currentJob.getRemainTime() == 0);
 }