/** Process.java - For each process/job/task in our schedule, we want * to keep track of its name, arrival time, total execution time required. * It would also be desirable to keep track of how much time is left * before the task is finished. * Also, the startTime and doneTime attributes will be useful when we * want to know the response time of a process. */ public class Process { private String name; private int arrivalTime; private int execTime; private int timeLeft; private int startTime; private int doneTime; public Process(String n, int start, int howLong) { name = n; arrivalTime = start; execTime = howLong; timeLeft = execTime; } // In case we want to start over, here's a way to re-set runtime params. public void reset() { timeLeft = execTime; startTime = doneTime = 0; } public String toString() { return "Process " + name + " arrives " + arrivalTime + ", requires " + execTime + ", " + timeLeft + " remaining :: startTime = " + startTime + ", doneTime = " + doneTime; } // It would be useful to have a number of get/set functions, plus // a way to reduce the amount of "time left" and a way to tell if we // are finished with a job. public String getName() { return name; } public int getArrivalTime() { return arrivalTime; } public int getExecTime() { return execTime; } public int getTimeLeft() { return timeLeft; } public void setTimeLeft(int howLong) { timeLeft = howLong; } public void reduceTimeLeft(int howLong) { timeLeft -= howLong; } public boolean isDone() { return timeLeft <= 0; } public void setStartTime(int when) { startTime = when; } public void setDoneTime(int when) { doneTime = when; } // Watch out: response time is done - arrival, not done - start ! public int findResponseTime() { return doneTime - startTime; } // Tell this process that it is finished (useful for shortest-job-next) public void makeDone() { timeLeft = 0; } }