home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / JSL.ZIP / JSL20 / examples / computer / ComputerSimulation.java < prev    next >
Encoding:
Java Source  |  1998-02-20  |  2.8 KB  |  88 lines

  1.  
  2. package examples.computer;
  3.  
  4.  
  5. import simula.* ;
  6. import simula.random.* ;
  7. import simula.simset.* ;
  8. import simula.simset.simulation.* ;
  9.  
  10. /**
  11.  * Multiprogrammed computer system
  12.  * @author Andrea Poltronieri
  13.  * @version 1.0 12 Feb 1998
  14.  */
  15.  
  16. public class ComputerSimulation extends Simulation{
  17.     // Global vars declaration ;
  18.     /** Simulation length */
  19.     public double simperiod ;
  20.     /** Number of jobs arrived */
  21.     public int result=0 ;
  22.     /** Active jobs queue */
  23.     public Head inner=null ;
  24.     /** Waiting jobs queue */
  25.     public Head outer=null ;
  26.     
  27.     /** Seed for random generators */
  28.     public int seed ;
  29.     
  30.     /** Free pages available */
  31.     public int free ;
  32.     
  33.     /** Process tha performs jobs scheduling and serving */
  34.     public Server server ;
  35.     
  36.     // Simulation parameters
  37.     /** Arrivals frequency */
  38.     public double arr ;
  39.     /** Total pages of memory */
  40.     public int m ;
  41.     /** Lower bound for number of pages requested */
  42.     public int m1 ;
  43.     /** Upper bound for number of pages requested */
  44.     public int m2 ;
  45.     /** Size for a quanta of service */
  46.     public double s ;
  47.     /** Probability of service request */
  48.     public double q ;
  49.     /** time of last event */
  50.     public double lastevent = 0;
  51.     
  52.  
  53.  
  54. /**
  55.  * Print credits on standar error.
  56.  */
  57. private static void credits ( ) {
  58.     System.err.println("***********************************************************") ;
  59.     System.err.println("*                    Example for Korretto                 *") ;
  60.     System.err.println("*  Multiprogrammed computer system                        *") ;
  61.     System.err.println("* see 'Simulation techiniques for discrete event systems' *") ;
  62.     System.err.println("*      I. Mitrani -- Cambridge University press           *") ;
  63.     System.err.println("*  ex 3.3                                                 *") ;
  64.     System.err.println("***********************************************************") ;
  65.     System.err.println("*  author : Andrea Poltronieri                            *") ;
  66.     System.err.println("*  Verona University                                      *") ;
  67.     System.err.println("*    e-mail : poltro@arena.sci.univr.it                     *") ;
  68.     System.err.println("*  http://arena.sci.univr.it/~poltro                      *") ;
  69.     System.err.println("***********************************************************") ;
  70. return;
  71. }
  72. /**     
  73.   * Start the simualtion, instantiating a new Simulation and launching the main program
  74.   * @param  args[] Ignored
  75.   * @see simula.simset.simulation.Simulation
  76.   * @see simula.simset.simulation.SimulationMain
  77. */
  78. public static void main(String args[]) {
  79.     try {
  80.             credits() ;
  81.             ComputerSimulation sim = new ComputerSimulation();
  82.             ComputerMain main = new ComputerMain(sim);
  83.         } catch (Exception e) { 
  84.             System.err.println ("Exception caught while lanching Computer :\n"+e) ;
  85.         }    
  86.     return;
  87. }
  88. }