* Simulation of a telephone system (with president line). * G. Gordon. Figure 12-9/10-7 POISS FUNCTION RN1,C24 ; Function for inter arrival time interval (Poisson) 0.0,0.0/0.1,0.104/0.2,0.222/0.3,0.355/0.4,0.509/0.5,0.69/ 0.6,0.915/0.7,1.2/0.75,1.38/0.8,1.6/0.84,1.83/0.88,2.12/ 0.9,2.3/0.92,2.52/0.94,2.81/0.95,2.99/0.96,3.2/0.97,3.5/ 0.98,3.9/0.99,4.6/0.995,5.3/0.998,6.2/0.999,7.0/0.9997,8.0 * The phone call process GENERATE 12,FN$POISS ; Interarrival time of calls (Poisson distributed) TEST G V$FL,2,ABND ; Test if system is full (all lines in use). ASN1 ASSIGN ORIGIN,V$LINE ; Determine origin line. Store in param named ORIGIN. GATE LR P$ORIGIN,ASN1 ; Test whether origin is busy ASN2 ASSIGN DEST,V$LINE ; Pick a destination line. Store in parameter named DEST. TEST NE P$ORIGIN,P$DEST,ASN2 ; Retry if ORIGIN == DEST for this call LOGIC S P$ORIGIN ; Set the origin line busy TRANSFER BOTH,,BLKD ; Try to obtain a link GETL ENTER LINKS ; Get link GATE LR P$DEST,BUSY ; Test for destination busy LOGIC S P$DEST ; Make destination busy MARK ; Reset transit timer ADVANCE 120,FN$POISS ; Talk TABULATE TTIME ; Tabulate talk time LOGIC R P$DEST ; Destination hangs up LOGIC R P$ORIGIN ; Origin hangs up LEAVE LINKS ; Free link CKCH TEST G CH$WAIT,0,TERM ; Test if there are waiting calls GATE LR 1,GETF ; Check whether line 1 (president) is free UNLINK WAIT,ULKDP,1,DEST,1,GETF ; Connect call to the president (line 1) first TERM TERMINATE ; Normal end of a succesful call GETF UNLINK WAIT,ULKD,1 ; Connect first (in priority queue WAIT) waiting call TRANSFER ,TERM ABND TERMINATE ; Abandon call BLKD MARK ; Reset timer LINK WAIT,P$ORIGIN ; Priority queue: lowest call origin first BUSY LEAVE LINKS ; Free link LOGIC R P$ORIGIN ; Origin hangs up TERMINATE ULKDP SAVEVALUE NUMPRESCALLS+,1 ; Increment number of calls to president counter by 1 ULKD TABULATE WAITT ; Tabulate wait time on WAIT chain TRANSFER ,GETL ; now allowed to get a line * The clock process CLOCK GENERATE 60 ; One clock tick every minute TERMINATE 1 * Declarations LINKS STORAGE 10 ; Number of links FL VARIABLE X$LINES-2#S$LINKS ; Number of free lines LINE VARIABLE X$LINES#RN1/1000+1 ; Randomly chosen line TTIME TABLE M1,10,10,100 ; Talk time distribution WAITT TABLE M1,10,10,30 ; Wait time (on WAIT chain) distribution * The experiment: GPSS control statements INITIAL X$LINES,50 ; Set the total number of lines INITIAL X$NUMPRESCALLS,0 ; Counter for the number of times the president gets called START 10,NP ; Warmpup (10 minutes), don't print report RESET ; Wipe out transient statistics START 1440 ; Main run (24 hours)