<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">public class Example {

    public static void main (String[] args) {

	int numFrames = 0;

	int numPages = 0;

	int numReferences = 0;

	

	try {

	    if (args.length != 3) {

		throw new NumberFormatException();

	    }



	    numFrames = Integer.parseInt(args[0]);

	    numPages = Integer.parseInt(args[1]);

	    numReferences = Integer.parseInt(args[2]);

	}

	catch (NumberFormatException e) {

	    System.out.println("USAGE: java Example &lt;numFrames&gt; &lt;numPages&gt; &lt;numReferences&gt;.");

	    System.exit(0);

	}



	MemoryInterface mi = new MemoryInterface(numFrames);

	ExamplePageManager pm = new ExamplePageManager(numPages);

	Simulator.History history;

	

	// String Reference Generator. 

        int refstr[] = new int[numReferences];

	for (int i=0; i&lt;numReferences; i++) {

	    refstr[i] = (i/2)%numPages;

	}

	StaticReferenceGenerator srg = new StaticReferenceGenerator(numPages, refstr);

	Simulator simulator1 = new Simulator(numReferences, pm, srg, mi);

	System.out.println("Starting simulation with static generator numFrames = "+numFrames+", numPages = "+numPages+", numReferences = "+numReferences+".\n");	

	history = simulator1.simulate();

	history.print();



	// Random Reference Generator. 

	RandomReferenceGenerator rrg = new RandomReferenceGenerator(numPages);

	Simulator simulator2 = new Simulator(numReferences, pm, rrg, mi);

	System.out.println("\nStarting simulation with random generator numFrames = "+numFrames+", numPages = "+numPages+", numReferences = "+numReferences+".\n");	

	history = simulator2.simulate();

	history.print();

	

	// Local Reference Generator. 

	LocalReferenceGenerator lrg = new LocalReferenceGenerator(numPages, (float)0.9, numFrames, numReferences/3);

	Simulator simulator3 = new Simulator(numReferences, pm, lrg, mi);

	System.out.println("\nStarting simulation with local generator numFrames = "+numFrames+", numPages = "+numPages+", numReferences = "+numReferences+".\n");	

	history = simulator3.simulate();

	history.print();

    }

}

</pre></body></html>