com.jimweller.cpuscheduler
Class Process

java.lang.Object
  extended bycom.jimweller.cpuscheduler.Process

public class Process
extends java.lang.Object

An aggregate data type to represent a process to schedule. It will maintain all of it's state internally.

Author:
Jim Weller

Field Summary
(package private)  boolean active
          A way to see if a process is scheduled to run this cycle
(package private)  long arrival
          The actual time the process arrived.
(package private)  boolean arrived
          a way to check if a process has occured yet
(package private)  long burst
          Process' CPU burst time.
(package private)  long delay
          Delay of arrival.
(package private)  long finish
          The time that the process ends execution.
(package private)  boolean finished
          A way to see if a process is complete
(package private)  long initBurst
          Store original burst state.
(package private)  long lifetime
          Measure of the total time a process was in the clutches of the scheduler.
(package private) static long nextPID
          Store the value of the next pid to use.
(package private)  long PID
          The process' identification number.
(package private)  long priority
          Execution priority.
(package private)  long response
          The measure of time after arrival that it took to begin execution
(package private)  long start
          The time that the process firsts begins execution.
(package private)  boolean started
          A way to check if a process has started running yet.
(package private)  long wait
          The total amount of time the process spent waiting.
 
Constructor Summary
(package private) Process()
          Default constructor.
(package private) Process(long b, long d, long p)
          Articulate constructor.
 
Method Summary
 void executing(long timeNow)
          Go through the motions of running one cycle on a process.
 long getArrivalTime()
          Get the value of arrival.
 long getBurstTime()
          Get the value of burst.
 long getDelayTime()
          Get the value of delay.
 long getFinishTime()
          Get the value of finish.
 long getInitBurstTime()
          Get the initial burst value of this process.
 long getLifetime()
          Get the value of lifetime
 long getPID()
          Get the value of PID.
 long getPriorityWeight()
          Get the value of priority.
 long getResponseTime()
          Get the value of response time.
 long getStartTime()
          Get the value of start.
 long getWaitTime()
          Get the value of wait.
 boolean isActive()
          Get the value of active.
 boolean isArrived()
          Get the value of arrived.
 boolean isFinished()
          Get the value of finished.
 boolean isStarted()
          Get the value of started.
 void print()
          Show state of process on the terminal
 void printCSV()
          Print comma seperated values to the terminal
 void printCSV(java.io.PrintWriter pw)
          Print comma seperated values list to a PrintWriter object.
 void println()
          Show state on a line.
 void restore()
          Restores the process to it's original state.
 void setArrivalTime(long v)
          Set the value of arrival.
 void waiting(long timeNow)
          The inverse of executing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PID

long PID
The process' identification number. It must be unique.


nextPID

static long nextPID
Store the value of the next pid to use. There is no garbage collection. I just take the next available number. It is the same variable in *all* instances of a process.


burst

long burst
Process' CPU burst time. The total amount of CPU time that a process needs in seconds. [0 - 100].


initBurst

long initBurst
Store original burst state. To show total an remaining I want to know what the original CPU burst of a process was. The variable 'burst' will store the "active" state


delay

long delay
Delay of arrival. How long after the previous process arrival does this process arrive? It is a time offset in seconds. [0 - 95]


priority

long priority
Execution priority. The weight that this process has. It aids the scheduler in some premptive algorithms. [0(low) - 9 (high)]


arrival

long arrival
The actual time the process arrived. This will be set by the scheduler.


start

long start
The time that the process firsts begins execution. This will be set by the scheduler.


finish

long finish
The time that the process ends execution. This will be set by the scheduler.


wait

long wait
The total amount of time the process spent waiting. Measured from the time it arrives to the time it finishes


response

long response
The measure of time after arrival that it took to begin execution


lifetime

long lifetime
Measure of the total time a process was in the clutches of the scheduler. Whether ready or waiting or running the full lifecycle of this process


arrived

boolean arrived
a way to check if a process has occured yet


started

boolean started
A way to check if a process has started running yet.


finished

boolean finished
A way to see if a process is complete


active

boolean active
A way to see if a process is scheduled to run this cycle

Constructor Detail

Process

Process()
Default constructor. Randomly generate a process and fills in fields using the bounds specified above.


Process

Process(long b,
        long d,
        long p)
Articulate constructor. No random generation is done on the programmers behalf. It is assumed that all values will be within the above parameters. This method is useful for building a queue of process where the data comes from a file or other source

Parameters:
b - The burst time of the process.
d - The delay in process arrival mesured from the arrival of the previous process.
p - The priority weight of the process.
Method Detail

executing

public void executing(long timeNow)
Go through the motions of running one cycle on a process. uses current time to check if certain events have occured (e.g. arrival, start, finish) and then sets the state of those events booleans.


waiting

public void waiting(long timeNow)
The inverse of executing. Go through the motions of waiting for cpu time. Use current time to check if this was our arrival time.


print

public void print()
Show state of process on the terminal


println

public void println()
Show state on a line. For tabular formats. Must figure out how to get table formatting. Oh, to say %8ld in java.


printCSV

public void printCSV()
Print comma seperated values to the terminal


printCSV

public void printCSV(java.io.PrintWriter pw)
Print comma seperated values list to a PrintWriter object.


getResponseTime

public long getResponseTime()
Get the value of response time.

Returns:
Value of response time .

getWaitTime

public long getWaitTime()
Get the value of wait.

Returns:
Value of wait.

getFinishTime

public long getFinishTime()
Get the value of finish.

Returns:
Value of finish.

getStartTime

public long getStartTime()
Get the value of start.

Returns:
Value of start.

getArrivalTime

public long getArrivalTime()
Get the value of arrival.

Returns:
Value of arrival.

setArrivalTime

public void setArrivalTime(long v)
Set the value of arrival.

Parameters:
v - Value to assign to arrival.

getPriorityWeight

public long getPriorityWeight()
Get the value of priority.

Returns:
Value of priority.

getDelayTime

public long getDelayTime()
Get the value of delay.

Returns:
Value of delay.

getBurstTime

public long getBurstTime()
Get the value of burst.

Returns:
Value of burst.

getInitBurstTime

public long getInitBurstTime()
Get the initial burst value of this process.

Returns:
Value of initBurst.

getPID

public long getPID()
Get the value of PID.

Returns:
Value of PID.

getLifetime

public long getLifetime()
Get the value of lifetime

Returns:
current lifetime in the scheduling queue

restore

public void restore()
Restores the process to it's original state. For rerunning a data set maybe under different circumstances


isActive

public boolean isActive()
Get the value of active.

Returns:
Value of active.

isFinished

public boolean isFinished()
Get the value of finished.

Returns:
Value of finished.

isStarted

public boolean isStarted()
Get the value of started.

Returns:
Value of started.

isArrived

public boolean isArrived()
Get the value of arrived.

Returns:
Value of arrived.