|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jimweller.cpuscheduler.CPUScheduler
CPUScheduler runs a simulation of one of four different scheduling algorithms (FCFS,SJF,ROUNDROBIN,PRIORITY). It can be set to run the whole simulation automatically in one fell swoop, or the programmer can imcrement on a step by step basis.
Field Summary | |
(package private) int |
activeIndex
The index into the vector/array/readyQueue. |
(package private) Process |
activeJob
A reference to the currently active job. |
(package private) int |
algorithm
The algorithm to use for this simulation. |
(package private) java.util.Vector |
allProcs
The collection of all processes involved in this simulation. |
(package private) long |
busy
The amount of elapsed time that the CPU was kept busy. |
(package private) long |
currentTime
This simulates elapsed time. |
(package private) static int |
DEF_PROC_COUNT
The default number of processes to randomly generate. |
static int |
FCFS
A constant for use in specifying the First Come First Serve scheduling algorithm |
(package private) long |
idle
The amount of elapsed idle time. |
(package private) java.util.Vector |
jobQueue
The collection of all jobs that will be used |
(package private) int |
maxResponse
|
(package private) int |
maxTurn
|
(package private) int |
maxWait
|
(package private) double |
meanResponse
|
(package private) double |
meanTurn
|
(package private) double |
meanWait
|
(package private) int |
minResponse
|
(package private) int |
minTurn
|
(package private) int |
minWait
|
(package private) boolean |
preemptive
Whether to use premption for the SJF and Priority algorithms. |
(package private) boolean |
priority
Whether to use priority weights for the round robin algorithm. |
static int |
PRIORITY
A constant for use in specifying the Priority Queue scheduling algorithm |
(package private) int |
procsIn
The number of jobs submitted for execution. |
(package private) int |
procsOut
the number of jobs that have been executed to completion. |
(package private) long |
quantum
for use in the round robin algorithm. |
(package private) long |
quantumCounter
A count down to when to interrupt a process because it's timeslice is over. |
(package private) java.util.Vector |
readyQueue
The collection of all jobs that have arrived and require CPU time. |
static int |
ROUNDROBIN
A constant for use in specifying the Round Robin scheduling algorithm |
(package private) double |
sDevResponse
|
(package private) double |
sDevTurn
|
(package private) double |
sDevWait
|
static int |
SJF
A constant for use in specifying the Shortes Job First scheduling algorithm |
(package private) long |
turnCounter
Only for the priority round robin algorithm, this variable keeps track of the number of consecutive timeslices a process has consumed. |
Constructor Summary | |
(package private) |
CPUScheduler()
Default constructor which builds DEF_PROC_COUNT randomly generated processes and loads them into the job queue |
(package private) |
CPUScheduler(java.io.File filename)
Articulate constructor that reads the process data from a file. |
(package private) |
CPUScheduler(java.lang.String filename)
Articulate constructor that reads the process data from a file. |
(package private) |
CPUScheduler(java.util.Vector ap)
Articulate constructor that allows the programmer to design his/her own Vector of processes and use them in the scheduler |
Method Summary | |
(package private) void |
buildRandomQueue()
Empty and populate a CPUScheduler |
(package private) void |
cleanUp()
Purge the runtime queues |
(package private) void |
Dispatch()
Actually run the active job and wait the rest of them |
(package private) Process |
findEarliestJob(java.util.Vector que)
FCFS: Get the job that got here first |
(package private) Process |
findLoftiestJob(java.util.Vector que)
find the job with the highest priority In case of tie take first in the queue |
(package private) Process |
findNextJob(java.util.Vector que)
RR: get the next job we should run (could be the one we're running). |
(package private) Process |
findShortestJob(java.util.Vector que)
SJF: Locate the smallest job in a queue |
Process |
getActiveProcess()
Get the Process that is actively being executed |
int |
getAlgorithm()
Get the value of algorithm. |
java.lang.String |
getAlgorithmName()
Get a string with the current algorithm's name |
long |
getBusyTime()
Get the amount of time the CPU has been used so far. |
long |
getIdleTime()
Get the number of idle cpu cycles. |
java.util.Vector |
getJobs()
Get all jobs |
double |
getLoad()
Get the system load. |
int |
getMaxResponse()
Get the maximum process response time |
int |
getMaxTurn()
Get the maximum process turn around time |
int |
getMaxWait()
Get the maximum process wait time |
double |
getMeanResponse()
Get the mean process response time |
double |
getMeanTurn()
Get the mean process turn around time |
double |
getMeanWait()
Get the mean process wait time |
int |
getMinResponse()
Get the minimum process response time |
int |
getMinTurn()
Get the minimum process turn around time |
int |
getMinWait()
Get the minimum process wait time |
boolean |
getPreemption()
Get the value of preemptive. |
boolean |
getPriority()
Get the value of priority. |
long |
getProcsIn()
Get the number of recieved jobs. |
long |
getProcsOut()
Get the number of completed processes . |
long |
getQuantum()
Get the value of quantum. |
double |
getStdDevResponse()
Get the standard deviation in process response time |
double |
getStdDevTurn()
Get the standard deviation in process turn around time |
double |
getStdDevWait()
Get the standard deviation in process wait time |
long |
getTotalTime()
Get the total time this simulation has been running. |
private void |
harvestStats()
Loop through the job queue and grab important statistics |
void |
LoadJobQueue(java.util.Vector jobs)
Load all the jobs into the job queue and setup their arrival times |
(package private) void |
LoadReadyQueue()
Check for new jobs. |
boolean |
nextCycle()
Just run one cycle of the simulation. |
void |
print()
Dump to terminal. |
void |
printCSV()
kindof ugly table to import into spreadsheet. |
void |
printCSV(java.io.PrintWriter pw)
kindof ugly table to import into spreadsheet. |
void |
printReadyQueue()
Dump ready queue to terminal. |
void |
printTable()
kindof nice looking table. |
(package private) void |
PurgeJobQueue()
Get rid of jobs that are done |
(package private) void |
PurgeReadyQueue()
Remove finished jobs. |
void |
restore()
Restore time and statisitic variables to their defaults. |
(package private) void |
RunFCFS(java.util.Vector jq)
Do the FCFS scheduling algorithm |
(package private) void |
RunPriority(java.util.Vector jq)
Do the Priority scheduling algorithm |
(package private) void |
RunRoundRobin(java.util.Vector jq)
Do the RR scheduling algorithm |
(package private) void |
RunSJF(java.util.Vector jq)
Do the SJF scheduling algorithm. |
(package private) void |
Schedule()
Use the appropriate scheduler to choose the next process. |
void |
setAlgorithm(int algo)
Set the value of algorithm. |
void |
setPreemption(boolean v)
Set the value of preemptive. |
void |
setPriority(boolean v)
Set the value of priority. |
void |
setQuantum(long v)
Set the value of quantum. |
void |
Simulate()
Run the whole simulation in one while loop |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FCFS
public static final int SJF
public static final int PRIORITY
public static final int ROUNDROBIN
static final int DEF_PROC_COUNT
long currentTime
long idle
long busy
long quantum
long quantumCounter
long turnCounter
int procsIn
int procsOut
boolean preemptive
boolean priority
int algorithm
java.util.Vector allProcs
java.util.Vector jobQueue
java.util.Vector readyQueue
Process activeJob
int activeIndex
int minWait
int maxWait
double meanWait
double sDevWait
int minResponse
int maxResponse
double meanResponse
double sDevResponse
int minTurn
int maxTurn
double meanTurn
double sDevTurn
Constructor Detail |
CPUScheduler()
CPUScheduler(java.util.Vector ap)
CPUScheduler(java.lang.String filename)
filename
- a string containing the file to openCPUScheduler(java.io.File filename)
filename
- A File object to read data fromMethod Detail |
void buildRandomQueue()
void Schedule()
void Dispatch()
void RunFCFS(java.util.Vector jq)
void RunSJF(java.util.Vector jq)
void RunPriority(java.util.Vector jq)
void RunRoundRobin(java.util.Vector jq)
Process findNextJob(java.util.Vector que)
Process findShortestJob(java.util.Vector que)
Process findEarliestJob(java.util.Vector que)
Process findLoftiestJob(java.util.Vector que)
private void harvestStats()
void LoadReadyQueue()
void PurgeReadyQueue()
void PurgeJobQueue()
public void LoadJobQueue(java.util.Vector jobs)
public void print()
public void printReadyQueue()
public void printTable()
public void printCSV()
public void printCSV(java.io.PrintWriter pw)
public boolean getPreemption()
public void setPreemption(boolean v)
v
- Value to assign to preemptive.public void setAlgorithm(int algo)
algo
- The algorithm to use for this simualtion.public int getAlgorithm()
public long getIdleTime()
public long getTotalTime()
public long getBusyTime()
public long getQuantum()
public void setQuantum(long v)
v
- Value to assign to quantum.public boolean getPriority()
public void setPriority(boolean v)
v
- Value to assign to priority.public long getProcsOut()
public long getProcsIn()
public double getLoad()
public Process getActiveProcess()
public void Simulate()
public boolean nextCycle()
void cleanUp()
public void restore()
public java.util.Vector getJobs()
public double getMeanWait()
public int getMinWait()
public int getMaxWait()
public double getStdDevWait()
public double getMeanResponse()
public int getMinResponse()
public int getMaxResponse()
public double getStdDevResponse()
public double getMeanTurn()
public int getMinTurn()
public int getMaxTurn()
public double getStdDevTurn()
public java.lang.String getAlgorithmName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |