/******* ** ** To compile: pcc cqnf2.pc -o cqnf2.seq -lm ** Converted to PARSEC on 10-9-97 by Monnica Terwilliger ** *******/ /****************************************************************** ** ** 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 #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 message Value { float val;}; message Clear {}; message Output { char filename[MAXNAME]; }; message Terminate {}; message job { int stime; int count;}; message idmsg { ename id;}; entity queue(int, int, int, ename); entity router(int, int, int, ename [N]); entity basic_stats (char [MAXTITLE]); int iurand(int, int, unsigned short[3]); int expon(int, unsigned short[3]); entity basic_stats (char title[MAXTITLE]) { float total, minimum, temp, maximum, mean, t1; int count; FILE *out; out = NULL; total=0; minimum=LARGE; maximum=0; count=0; for (;;) { receive (Value value) { count++; temp=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, unsigned short seed[3]) { extern double log(); return(int)((-log((double)(1.0-pc_erand(seed)))) * ((double) mean)); }