home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-20 | 1.3 KB | 58 lines |
-
- package examples.computer;
-
-
- import simula.*;
- import simula.simset.simulation.*;
- import simula.random.* ;
- /**
- * Activity wich creates new jobs
- * @author Andrea Poltronieri
- * @version 1.0 12 Feb 1998
- */
-
- public class Arrivals extends simula.simset.simulation.Process {
-
-
-
- /**
- * @param _sim The active Simulation
- */
- public Arrivals (Simulation _sim){
- super(_sim);
- }
- /**
- * Executes actions for this object. Called by simulation on activate
- * @see simula.simset.simulation.Simulation
- */
-
- public void run() {
- ComputerSimulation sim = (ComputerSimulation) this.sim ;
- Negexp negexp=new Negexp(sim.seed,sim.arr) ;
- Randint randint=new Randint(sim.seed,sim.m1,sim.m2) ;
- //declare local integer for number of items in batch and enter infinite loop
- int number ;
- Job newjob ;
- try {
- while (true) {
- sim.hold(negexp.draw().asReal()) ;
- newjob=new Job(sim,randint.draw().asInteger()) ;
- if (sim.free>=newjob.req) {
- //Enough pages available -> go into inner queue
- newjob.into(sim.inner) ;
- sim.free-=newjob.req ;
- }
- else
- newjob.into(sim.outer) ;
-
- if (sim.server.idle())
- sim.activate(sim.server) ;
- }
-
-
- } catch (Exception e ) {
- System.err.println ("Arrivals exception caught : " + e ) ;
- System.exit(1) ;
- }
- }
- }