Class Sim

java.lang.Object
  |
  +--Sim

public class Sim
extends java.lang.Object

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.


Field Summary
static int BLOCKSIZE
          The size of a disk block, in bytes
static int DISK_TIME
          The amount of time it takes for a disk operation
static double ODD_BURST_PROB
          Probability of an "unusual" CPU burst.
static int SWAP_OVERHEAD
          Penalty for starting or stopping a process.
static boolean traceFlag
          Trace flag.
 
Constructor Summary
Sim()
           
 
Method Summary
static void debug(java.lang.String msg)
          Print a message unconditionally.
static int debugLevel()
          Return the current level of debugging.
static void mainLoop(java.lang.String scheduler, java.lang.String fname, int timer)
          This is the main program that runs the simulation.
static void moreVerbose()
          Increase the verbosity of debugging.
static int now()
          Get the current time, in simulated milliseconds since startup.
static void pl(java.lang.Object msg)
          Print a message unconditionally without a header.
static java.lang.String tod(int time)
          Converts 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.
static boolean tracing()
          Indicate whether all events should be traced.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISK_TIME

public static final int DISK_TIME
The amount of time it takes for a disk operation

BLOCKSIZE

public static final int BLOCKSIZE
The size of a disk block, in bytes

SWAP_OVERHEAD

public static final int SWAP_OVERHEAD
Penalty for starting or stopping a process.

ODD_BURST_PROB

public static final double ODD_BURST_PROB
Probability of an "unusual" CPU burst.
See Also:
Job#newBurst()

traceFlag

public static boolean traceFlag
Trace flag.
Constructor Detail

Sim

public Sim()
Method Detail

now

public static int now()
Get the current time, in simulated milliseconds since startup.
Returns:
the current time.

moreVerbose

public static void moreVerbose()
Increase the verbosity of debugging.

debugLevel

public static int debugLevel()
Return the current level of debugging.

tracing

public static boolean tracing()
Indicate whether all events should be traced.

mainLoop

public static void mainLoop(java.lang.String scheduler,
                            java.lang.String fname,
                            int timer)
This is the main program that runs the simulation.
Parameters:
scheduler - the name of a class that extends Scheduler, which is used to schedule the CPU.
fname - the name of the trace file describing the jobs.
timer - the interval between clock interrupts (0 means the interval timer is turned off).

debug

public static void debug(java.lang.String msg)
Print a message unconditionally.
Parameters:
msg - the message to print.

pl

public static void pl(java.lang.Object msg)
Print a message unconditionally without a header.
Parameters:
msg - the message to print.

tod

public static java.lang.String tod(int time)
Converts 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. Too bad Java doesn't have sprintf!
Parameters:
time - the time of day in ms past midnight
Returns:
a string version of the time.