/****************************************************************** ** ** Simulation of a Closed Queueing Network with FCFS servers ** ** This is a simulation of a closed network with N fully connected ** switches. Each switch is a tandem queue of Q fifo servers. ** A job that arrives at a queue is served sequentially (FCFS) ** by the Q servers and is thereafter routed to one of the ** N neighboring switches (including itself) with equal ** probability. ** Entities defined in the program: ** (1) driver: initiates the simulation ** (2) router: distributes jobs to N neighbors ** (3) queue: models the tandem queue ** ******************************************************************/ #include "maisie.h" #include #define MAXN 16 #define MAXNSRVR 20 #define NSWTCH 16 #define NSRVR 5 #define NJOB 96 #define MAXCLOK "3000" #define MEAN 10 #define MAXTRIP 20 #define MAX(A, B) (A>B?A:B) entity driver{argc,argv} int argc; char **argv; { ename q[MAXNSRVR+1][MAXN]; int i,j; printf("\nCQNF Configuration simulated:\n"); printf("\t Number of routers =\t%d\n", NSWTCH); printf("\tInitial no. of jobs/router =\t%d\n", NJOB); printf("\t Number of servers/queue =\t%d\n", NSRVR); printf("\t MAXCLOCK =\t%s\n", MAXCLOK); maxclock(MAXCLOK); if(NSRVR < 1 || NSWTCH < 1){ printf(" can't simulate less than 1 servers or switches\n"); } for (i=0;i 0){ ret = (v%t + b)%t; return(ret); } else { fprintf(stderr,"iurand: wrong range (%d -- %d)\n", b, t); return -1; } } int expon(mean,seed) int mean; unsigned short seed[3]; { extern double erand48(); extern double log(); return ((int)((-log((double)(1.0-erand48(seed)))) * ((double) mean)) +1); }