/******* ** ** To compile: mc cqnf2.m -o cqnf2 -lmaisie -lm ** *******/ /****************************************************************** ** ** 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" #define N 16 #define NSRVR 10 #define NJOB 16 #define MAXTRIP 10 #define MEAN 10 #define MAX(A, B) (A>B?A:B) extern entity basic_stats{}; extern entity router{}; extern entity queue{}; entity driver{} { ename rtr[N],q[N],stat1; int i; srand48(1000); stat1 = new basic_stats{"Average System Time"}; for (i=0;i 0) return((v % t) + b); else { fprintf(stderr,"iurand: wrong range (%d -- %d)\n", b, t); return -1; } } int expon(mean) int mean; { extern double drand48(); extern double log(); return(int)((-log((double)(1.0-drand48()))) * ((double) mean)); } print_info() { printf("\nCQNF Configuration simulated:\n"); printf("\t Number of routers =\t%d\n", N); printf("\tInitial no. of jobs/router =\t%d\n", NJOB); printf("\t Number of servers/queue =\t%d\n", NSRVR); printf("\t Number of trips/job =\t%d\n", MAXTRIP); }