import java.io.*; import java.util.*; import java.lang.*; import java.net.*; import java.lang.Thread; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** This class is the API for simulation application programmer. It receives commandline * parameters, maps LPs to PES, initiates, runs and terminates the simulation. * @author Yin Xiong * @version 1.7 (09/2006) */ public class Sim{ /**The main function that runs the simulation. */ static public void main(String[] args) { MessagePool msgPool=new MessagePool(); GlobalNameServer gns=new GlobalNameServer(); Flag eosFlag=new Flag(); boolean endOfSim=false; Flag gvtFlag=new Flag(); int gvtClock=5; PE myPE=null; int sleepTime=300; int lpForMe=1; //how many LPs each PE will have except PE0 int lpForFirst=0; //how many LPs the first PE will have int lpForEach=0; //how many LPs each of the rest PE will have int lpTotal=0; //how many LPs altogether String myname=null; /**a vector of LP configuration information*/ Vector lpConfigInfoVector=new Vector(); String fileName; int numPEs; Creator creator; int len,tasks,me,size,rc; me=size=0; //get file name from command line if(args.length<4){ System.out.println("Usage: java Sim [config file name] [# of PEs][sleep time][GVT clock]"); System.exit(1); } else{ fileName=args[0]; //System.out.println("Config file: " +fileName + "\n"); numPEs=Integer.parseInt(args[1]); //System.out.println("Number of PEs: " + numPEs+ "\n"); sleepTime=Integer.parseInt(args[2]); //System.out.println("sleep time: " + sleepTime); gvtClock=Integer.parseInt(args[3]); System.out.println("GVT will be computed every " + gvtClock + " sim time"); //invoke Creator to parse config file creator=new Creator(); //process config file creator.procConfigFile(fileName, numPEs); //get LP info: how many LPs for each PE and the info for each LP lpConfigInfoVector=creator.getLPConfigInfo(); //for debugging only: check if LP config info is obtained correctly for(int i=0;i