|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--Sim
Class Sim is the main driver for the whole simulation. It contains the mainLoop processing loop, as well as various various methods for gathering and printing statistics and generating debugging output. All members are static. The only public members are the methods now(), moreVerbose(), db(), and tod().
| Field Summary | |
private static int |
arrivalCount
The number of job arrivals |
private static int |
ARRIVALS_SLOT
Slot number for the JobArrivals device. |
static int |
BLOCKSIZE
The size of a disk block, in bytes |
private static int |
CLOCK_SLOT
Slot number for the Clock device. |
private static java.util.Vector |
completed
Information about completed Jobs. |
private static int |
CPU_SLOT
Slot number for the CPU device. |
private static Scheduler |
cpuScheduler
Scheduler for the cpu |
private static int |
currentTime
The current simulated time (in ms since start) |
private static java.lang.String[] |
dev_name
For debugging: slot names |
private static Device[] |
device
An array of devices, index by one of the following slot numbers |
private static int |
DEVICES
Number of devices "installed" |
private static int |
DISK_SLOT
Slot number for the Disk device. |
static int |
DISK_TIME
The amount of time it takes for a disk operation |
private static Scheduler |
diskScheduler
Scheduler for the disk |
static double |
ODD_BURST_PROB
Probability of an "unusual" CPU burst. |
static int |
QUANTUM
The quantum for round-robin scheduling |
static int |
SWAP_OVERHEAD
Penalty for starting and stopping a process. |
static boolean |
traceFlag
Trace flag. |
static int |
verbosity
Flag to control the verbosity of debugging output. |
| Constructor Summary | |
(package private) |
Sim()
|
| Method Summary | |
static void |
assert(boolean condition)
Crude assertion checking. |
static void |
db(int level,
java.lang.Object o1,
java.lang.Object o2)
Overloaded version of the debug method. |
static void |
db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
Overloaded version of the debug method. |
static void |
db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
Overloaded version of the debug method. |
static void |
db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
Overloaded version of the debug method. |
static void |
db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
int o6)
Overloaded version of the debug method. |
static void |
db(int level,
java.lang.String msg)
Print a message if verbosity >= level. |
static void |
db(java.lang.String msg)
Print a message unconditionally. |
private static int |
firstInterrupt()
Query the devices to see which one will be the first to interrupt. |
(package private) static void |
mainLoop(java.lang.String fname)
This is the main program that runs the simulation. |
static void |
moreVerbose()
Increase the verbosity. |
static int |
now()
Get the current time. |
static void |
pr(java.lang.String msg)
Print a message unconditionally without a header. |
private static void |
schedule(Job j,
Device cpu)
Utility routine to send a Job to the Disk, CPU, or completion as appropriate. |
static java.lang.String |
tod(int time)
Convert a time-stamp from ms to time of day in the format h:mm:ss.mmm This used to be written more "cleanly", but it turned out to consume a huge fraction of the entire time taken by the program, so it was re-written to avoid allocating and concatenating Strings until the very end. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int DISK_TIME
public static int QUANTUM
public static final int BLOCKSIZE
public static final int SWAP_OVERHEAD
public static final double ODD_BURST_PROB
Job.newBurst()private static int currentTime
private static final int DEVICES
private static Device[] device
private static final int ARRIVALS_SLOT
private static final int DISK_SLOT
private static final int CPU_SLOT
private static final int CLOCK_SLOT
private static final java.lang.String[] dev_name
private static Scheduler diskScheduler
private static Scheduler cpuScheduler
private static int arrivalCount
private static java.util.Vector completed
public static int verbosity
public static boolean traceFlag
| Constructor Detail |
Sim()
| Method Detail |
public static int now()
static void mainLoop(java.lang.String fname)
fname - the name of the trace file describing the jobs.
private static void schedule(Job j,
Device cpu)
j - the job to be dispatched.cpu - the CPU device.private static int firstInterrupt()
public static void moreVerbose()
public static void db(int level,
java.lang.String msg)
level - the verbosity level of this message.msg - the message.
public static void db(int level,
java.lang.Object o1,
java.lang.Object o2)
level - the verbosity level of this message.o1 - a parameter.o2 - a parameter.
public static void db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
level - the verbosity level of this message.o1 - a parameter.o2 - a parameter.o3 - a parameter.
public static void db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
level - the verbosity level of this message.o1 - a parameter.o2 - a parameter.o3 - a parameter.o4 - a parameter.
public static void db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
level - the verbosity level of this message.o1 - a parameter.o2 - a parameter.o3 - a parameter.o4 - a parameter.o5 - a parameter.
public static void db(int level,
java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
int o6)
level - the verbosity level of this message.o1 - a parameter.public static void db(java.lang.String msg)
msg - the message to print.public static void pr(java.lang.String msg)
msg - the message to print.public static void assert(boolean condition)
the - assertion.public static java.lang.String tod(int time)
time - the time of day in ms past midnight
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||