/******* ** ** To compile: mc cqnf2-new.m -o cqnf2-new -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 #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) #define MAXTITLE 70 #define LARGE 1.0e19 #define MAXNAME 64 entity basic_stats{char title[MAXTITLE]} { message value {float val;} value; message clear {} clear; message output { char filename[MAXNAME]; } output; message dump {} dump; message terminate {} terminat; float total,minimum,temp,maximum,mean, t1; int count; int notdump; FILE *out; out = NULL; total=0;minimum=LARGE;maximum=0;count=0; notdump=1; for (;;) wait until { mtype(value) { count++; temp=msg.value.val; total+=temp; if (temp>maximum) maximum=temp; if (temp 0) return((v % t) + b); else { fprintf(stderr,"iurand: wrong range (%d -- %d)\n", b, t); return -1; } } int expon(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); }