Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/21/demos.sim
There is 1 other file named demos.sim in the archive. Click here to see a list.
00010	OPTIONS(/E/C);
00020	EXTERNAL CLASS REPORT;
00030	
00040	REPORT CLASS DEMOS;
00050	BEGIN
00060	
00070	COMMENT----------E N T I T Y-------------------------;
00080	
00090	PROCESS CLASS ENTITY(TITLE);VALUE TITLE;TEXT TITLE;
00100	                            VIRTUAL: LABEL LOOP;
00110	BEGIN REAL TIMEIN;
00120	INTEGER PRIORITY, CYCLE, WANTS, SERIALNO, INTERRUPTED;
00130	REF(QUEUE)CURRENTQ;
00140	REF(ENTITY)OWNER;
00150	
00160	BOOLEAN PROCEDURE AVAIL;
00170	  AVAIL := OWNER == NONE;
00180	
00190	PROCEDURE COOPT;
00200	BEGIN IF OWNER =/= NONE THEN ERROR(1);
00210	OWNER :- CURRENT;
00220	IF ZYQTRACE THEN NOTE(1,"COOPTS",THIS ENTITY,CURRENTQ,0.0,0);
00230	IF CURRENTQ =/= NONE THEN DEPART;
00240	END***COOPT***;
00250	
00260	PROCEDURE INTERRUPT(N); INTEGER N;
00270	BEGIN
00280	IF CURRENTQ =/= NONE THEN DEPART;
00290	INTERRUPTED := N;
00300	REACTIVATE THIS ENTITY DELAY 0.0;
00310	IF ZYQTRACE THEN NOTE(24,"INTERRUPTS",THIS ENTITY,NONE,0.0,N);
00320	END***INTERRUPT***;
00330	
00340	PROCEDURE SCHEDULE(T); REAL T;
00350	BEGIN IF T < 0.0 THEN T := 0.0;
00360	IF SERIALNO = 0 THEN GETSERIALNO ELSE
00370	BEGIN IF OWNER == NONE THEN ERROR(4);
00380	OWNER :- NONE;
00390	END;
00400	IF CURRENTQ =/= NONE THEN DEPART;
00410	IF ZYQTRACE THEN NOTE(2, "SCHEDULES", THIS ENTITY, NONE, T, 0);
00420	ACTIVATE THIS ENTITY DELAY T;
00430	END***RELEASE***;
00440	
00450	REF(ENTITY)PROCEDURE PRED;
00460	BEGIN REF(LINK)E;
00470	E :- THIS LINK.PRED;
00480	IF E =/= NONE THEN PRED :- E QUA ENTITY;
00490	END***PRED***;
00500	
00510	REF(ENTITY)PROCEDURE SUC;
00520	BEGIN REF(LINK)E;
00530	E :- THIS LINK.SUC;
00540	IF E =/= NONE THEN SUC :- E QUA ENTITY;
00550	END***SUC***;
00560	
00570	REF(ENTITY)PROCEDURE NEXTENT;
00580	BEGIN REF(PROCESS)E;
00590	E :- NEXTEV;
00600	IF E =/= NONE THEN NEXTENT :- E QUA ENTITY;
00610	END***NEXTENT***;
00620	
00630	PROCEDURE REPEAT;
00640	BEGIN CYCLE := CYCLE+1;
00650	GOTO LOOP;
00660	END***REPEAT***;
00670	
00680	PROCEDURE JOIN(Q); REF(QUEUE)Q;
00690	BEGIN REF(ENTITY)E;
00700	CURRENTQ :- Q;
00710	TIMEIN   := TIME;
00720	INSPECT CURRENTQ DO
00730	BEGIN QINT := QINT + (TIMEIN-LASTTIME)*LENGTH;
00740	LASTTIME := TIMEIN;
00750	LENGTH := LENGTH+1;
00760	IF LENGTH > MAXLENGTH THEN MAXLENGTH := LENGTH;
00770	E :- ZYQQ.LAST;
00780	IF (IF E == NONE THEN TRUE ELSE E.PRIORITY >= PRIORITY)
00790	  THEN THIS ENTITY.INTO(ZYQQ) ELSE
00800	BEGIN E :- ZYQQ.FIRST;
00810	WHILE E.PRIORITY >= PRIORITY DO
00820	  E :- E.SUC;
00830	THIS ENTITY.PRECEDE(E);
00840	END;
00850	END;
00860	END***JOIN***;
00870	
00880	PROCEDURE DEPART;
00890	BEGIN REAL T;
00900	T := TIME;
00910	INSPECT CURRENTQ DO
00920	BEGIN QINT := QINT + (T-LASTTIME)*LENGTH;
00930	LENGTH    := LENGTH-1;
00940	LASTTIME  := T;
00950	N         := N+1;
00960	T         := LASTTIME-TIMEIN;
00970	IF T < 0.00001 THEN ZEROS := ZEROS+1;
00980	CUM := CUM+T;
00990	END;
01000	OUT;
01010	CURRENTQ :- NONE;
01020	END***DEPART***;
01030	
01040	PROCEDURE GETSERIALNO;
01050	BEGIN REF(ZYQENTTITLE)Z;
01060	SERIALNO := ZYQPSERNO := ZYQPSERNO+1;
01070	Z :- ZYQENTNAMES.FIRST;
01080	WHILE (IF Z == NONE THEN FALSE ELSE TITLE NE Z.T) DO
01090	  Z :- Z.SUC;
01100	IF Z == NONE THEN Z :- NEW ZYQENTTITLE(TITLE);
01110	TITLE :- BLANKS(Z.L+2);
01120	TITLE := Z.T;
01130	TITLE.SUB(Z.L+1, 2).PUTINT(Z.N);
01140	Z.N := Z.N+1;
01150	IF Z.N = 100 THEN Z.N := 0;
01160	END***GET SERIALNO***;
01170	
01180	IF TITLE.LENGTH > 12 THEN TITLE :- TITLE.SUB(1, 12);
01190	LOOP:;
01200	INNER;
01210	IF ZYQTRACE THEN NOTE(3, "***TERMINATES", NONE, NONE, 0.0, 0);
01220	END***ENTITY***;
01230	
01240	COMMENT----------R E S O U R C E S : R E S   A N D   B I N---;
01250	
01260	TAB CLASS RESOURCE(INITIALLY); INTEGER INITIALLY;
01270	BEGIN INTEGER EXTREME, TYPE, AVAIL;
01280	REAL LASTTIME, SINT;
01290	REF(QUEUE)ZYQQ;
01300	
01310	PROCEDURE RESET;
01320	BEGIN N := 0;
01330	SINT := 0.0;
01340	EXTREME := AVAIL;
01350	LASTTIME := RESETAT := TIME;
01360	ZYQQ.RESET;
01370	END***RESET***;
01380	
01390	PROCEDURE ZYQCOOPT(M); INTEGER M;
01400	BEGIN REAL T; BOOLEAN WAITS; REF(ENTITY)C;
01410	IF M < 1 THEN ERROR(5);
01420	C :- ZYQCURRENT QUA ENTITY;
01430	WAITS := IF M > AVAIL THEN TRUE ELSE IF ZYQQ.LENGTH = 0 THEN FALSE ELSE
01440	         ZYQQ.FIRST.PRIORITY >= C.PRIORITY;
01450	IF WAITS THEN
01460	BEGIN C.JOIN(ZYQQ);
01470	C.WANTS := M;
01480	IF ZYQTRACE THEN NOTE(4,"AWAITS",NONE,THIS RESOURCE,0.0,M);
01490	ZYQPASSIVATE;
01500	END ELSE
01510	BEGIN ZYQQ.ZEROS := ZYQQ.ZEROS+1;
01520	ZYQQ.N := ZYQQ.N+1;
01530	T := TIME;
01540	SINT := SINT + (T-LASTTIME)*AVAIL;
01550	LASTTIME := T;
01560	AVAIL := AVAIL-M;
01570	IF(IF TYPE=0 THEN AVAIL<EXTREME ELSE AVAIL>EXTREME)THEN
01580	  EXTREME := AVAIL;
01590	END;
01600	IF ZYQTRACE THEN NOTE(5,"SEIZES",NONE,THIS RESOURCE,0.0,M);
01610	END***ZYQCOOPT***;
01620	
01630	PROCEDURE ZYQSIGNAL(M); INTEGER M;
01640	BEGIN REF(ENTITY)E; REAL T;
01650	IF TYPE = 0 AND M > INITIALLY THEN ERROR(7);
01660	IF ZYQTRACE THEN NOTE(6,"RELEASES",NONE,THIS RESOURCE,0.0,M);
01670	T := TIME;
01680	SINT := SINT + (T-LASTTIME)*AVAIL;
01690	LASTTIME := T;
01700	AVAIL := AVAIL+M;
01710	N := N + 1;
01720	IF (IF TYPE=0 THEN AVAIL<EXTREME ELSE AVAIL>EXTREME) THEN
01730	  EXTREME := AVAIL;
01740	E :- ZYQQ.FIRST;
01750	WHILE (IF E == NONE THEN FALSE ELSE E.WANTS <= AVAIL) DO
01760	BEGIN E.DEPART;
01770	AVAIL := AVAIL - E.WANTS;
01780	IF(IF TYPE = 0 THEN AVAIL<EXTREME ELSE AVAIL>EXTREME) THEN
01790	  EXTREME := AVAIL;
01800	ACTIVATE E DELAY 0.0;
01810	E :- ZYQQ.FIRST;
01820	END;
01830	END***ZYQSIGNAL***;
01840	
01850	PROCEDURE REPORT;
01860	BEGIN REAL T, SPAN, X; INTEGER S;
01870	T := TIME;
01880	SPAN := T-RESETAT;
01890	ZYQWRITETRN;
01900	OUTINT(INITIALLY, 5);
01910	OUTINT(EXTREME, 5);
01920	OUTINT(AVAIL, 5);
01930	X := SINT + (T-LASTTIME)*AVAIL;
01940	IF SPAN < 0.00001 THEN OUTTEXT(MINUSES10) ELSE
01950	  PRINTREAL(IF TYPE=0 THEN (1.0-X/(INITIALLY*SPAN))*100.0 ELSE X/SPAN);
01960	IF ZYQQ.N > 0 THEN PRINTREAL(ZYQQ.CUM/ZYQQ.N) ELSE OUTTEXT(MINUSES10);
01970	OUTINT(ZYQQ.MAXLENGTH, 5);
01980	OUTIMAGE;
01990	END***REPORT***;
02000	
02010	IF INITIALLY < 0 THEN ERROR(8);
02020	AVAIL := EXTREME := INITIALLY;
02030	ZYQQ :- NEW QUEUE(NOTEXT);  ZYQQ.OUT;
02040	END***RESOURCE***;
02050	
02060	
02070	COMMENT------------------RES--------------------------------;
02080	
02090	RESOURCE CLASS RES;
02100	BEGIN
02110	
02120	PROCEDURE ACQUIRE(N); INTEGER N;
02130	  ZYQCOOPT(N);
02140	
02150	PROCEDURE RELEASE(N); INTEGER N;
02160	  ZYQSIGNAL(N);
02170	
02180	INTO(RESQ);
02190	END***RES***;
02200	
02210	
02220	COMMENT---------------B I N----------------------------------;
02230	
02240	RESOURCE CLASS BIN;
02250	BEGIN
02260	
02270	PROCEDURE TAKE(N); INTEGER N;
02280	  ZYQCOOPT(N);
02290	
02300	PROCEDURE GIVE(N); INTEGER N;
02310	  ZYQSIGNAL(N);
02320	
02330	TYPE := 1;
02340	INTO(BINQ);
02350	END***BIN***;
02360	
02370	
02380	COMMENT-------------Q U E U E--------------------------------;
02390	
02400	TAB CLASS QUEUE;
02410	BEGIN REF(HEAD)ZYQQ; BOOLEAN ZYQSLAVE;
02420	INTEGER LENGTH, ZEROS, MAXLENGTH;
02430	REAL QINT, LASTTIME, CUM;
02440	
02450	REF(ENTITY)PROCEDURE FIRST;
02460	BEGIN REF(LINK)E;
02470	E :- ZYQQ.FIRST;
02480	IF E IN ENTITY THEN FIRST :- E QUA ENTITY ELSE
02490	IF E =/= NONE THEN ERROR(25);
02500	END***FIRST***;
02510	
02520	REF(ENTITY)PROCEDURE LAST;
02530	BEGIN REF(LINK)E;
02540	E :- ZYQQ.LAST;
02550	IF E IN ENTITY THEN LAST :- E QUA ENTITY ELSE
02560	IF E =/= NONE THEN ERROR(26);
02570	END***LAST***;
02580	
02590	PROCEDURE SAVE(E); REF(ENTITY)E;
02600	BEGIN
02610	IF E == NONE THEN ERROR(35) ELSE E.JOIN(THIS QUEUE);
02620	END***SAVE***;
02630	
02640	PROCEDURE LISTMEMBERS;
02650	BEGIN REF(ENTITY)E; INTEGER K, L;
02660	SHORTPRINT;
02670	OUTTEXT("CONTENTS AT TIME = ");
02680	PRINTREAL(TIME);
02690	OUTIMAGE;  OUTIMAGE;
02700	E :- FIRST;
02710	WHILE E =/= NONE DO
02720	BEGIN K := K+1;
02730	L := L+1;
02740	IF L > 3 THEN
02750	BEGIN OUTIMAGE;
02760	L := 1;
02770	END;
02780	OUTINT(K, 3);
02790	OUTTEXT("==");
02800	OUTTEXT(E.TITLE);
02810	SYSOUT.SETPOS(24*L);
02820	OUTCHAR(',');
02830	E :- E.SUC;
02840	END;
02850	OUTIMAGE;
02860	EJECT(LINE+2);
02870	OUTIMAGE;
02880	END***LIST MEMBERS***;
02890	
02900	PROCEDURE REPORT;
02910	BEGIN REAL SPAN, T;
02920	ZYQWRITETRN;
02930	IF (IF THIS QUEUE IS CONDQ THEN THIS QUEUE QUA CONDQ.ALL ELSE FALSE) OR
02940	   ZYQSLAVE THEN ZYQSTARS := "*";
02950	OUTINT(MAXLENGTH, 6);
02960	OUTINT(LENGTH, 6);
02970	T := TIME;
02980	SPAN := T - RESETAT;
02990	OUTCHAR(' ');
03000	IF ABS(SPAN) < 0.00001 THEN OUTTEXT(MINUSES10) ELSE
03010	  PRINTREAL((QINT + (T-LASTTIME)*LENGTH)/SPAN);
03020	OUTINT(ZEROS, 6);
03030	OUTCHAR(' ');
03040	IF N > 0 THEN PRINTREAL(CUM/N) ELSE OUTTEXT(MINUSES10);
03050	OUTIMAGE;  IF ZYQSLAVE THEN OUTIMAGE;
03060	END***REPORT***;
03070	
03080	PROCEDURE RESET;
03090	BEGIN ZEROS := N := 0;
03100	QINT := CUM := 0.0;
03110	MAXLENGTH := LENGTH;
03120	LASTTIME := RESETAT := TIME;
03130	END***RESET***;
03140	
03150	ZYQQ :- NEW HEAD;
03160	INTO(QUEUEQ);
03170	END***QUEUE***;
03180	
03190	COMMENT-----------------W A I T Q-----------------------------;
03200	
03210	CLASS WAITQ(TITLE); VALUE TITLE; TEXT TITLE;
03220	BEGIN REF(QUEUE)MASTERQ, SLAVEQ;
03230	
03240	PROCEDURE WAIT;
03250	BEGIN REF(ENTITY)C, M;
03260	C :- ZYQCURRENT;
03270	C.JOIN(SLAVEQ);
03280	IF ZYQTRACE THEN NOTE(14,"WAITS",NONE,SLAVEQ,0.0,0);
03290	M :- MASTERQ.FIRST;
03300	IF M =/= NONE THEN ACTIVATE M AFTER C;
03310	ZYQPASSIVATE;
03320	END***WAIT***;
03330	
03340	PROCEDURE FIND(E, CC); NAME E, CC; REF(ENTITY)E; BOOLEAN CC;
03350	BEGIN REF(ENTITY)C, P;
03360	C :- ZYQCURRENT;
03370	E :- SLAVEQ.FIRST;
03380	WHILE (IF E == NONE THEN FALSE ELSE NOT CC) DO
03390	  E :- E.SUC;
03400	IF E =/= NONE THEN
03410	BEGIN
03420	IF ZYQTRACE THEN NOTE(15,"FINDS",E,SLAVEQ,0.0,0);
03430	E.COOPT;
03440	MASTERQ.N := MASTERQ.N+1;
03450	MASTERQ.ZEROS := MASTERQ.ZEROS +1;
03460	END ELSE
03470	BEGIN
03480	C.JOIN(MASTERQ);
03490	IF ZYQTRACE THEN NOTE(17,"WAITS",NONE,MASTERQ,0.0,0);
03500	ZYQPASSIVATE;
03510	L:E :- SLAVEQ.FIRST;
03520	WHILE (IF E == NONE THEN FALSE ELSE NOT CC) DO
03530	  E :- E.SUC;
03540	IF E =/= NONE THEN
03550	BEGIN IF ZYQTRACE THEN NOTE(15,"FINDS",E,SLAVEQ,0.0,0);
03560	E.COOPT;  P :- C.SUC;
03570	IF P =/= NONE THEN ACTIVATE P AFTER C;
03580	C.DEPART;
03590	END ELSE
03600	BEGIN ZYQPASSIVATE;
03610	GOTO L;
03620	END;
03630	END;
03640	END***FIND***;
03650	
03660	BOOLEAN PROCEDURE AVAIL(E, C); NAME E, C; REF(ENTITY)E; BOOLEAN C;
03670	BEGIN E :- SLAVEQ.FIRST;
03680	WHILE (IF E == NONE THEN FALSE ELSE NOT C) DO
03690	  E :- E.SUC;
03700	AVAIL := E =/= NONE;
03710	END***AVAIL***;
03720	
03730	
03740	REF(ENTITY)PROCEDURE COOPT;
03750	BEGIN REF(ENTITY)C, P;
03760	C :- ZYQCURRENT;
03770	IF SLAVEQ.LENGTH = 0 THEN
03780	BEGIN C.JOIN(MASTERQ);
03790	IF ZYQTRACE THEN NOTE(17,"WAITS",NONE,MASTERQ,0.0,0);
03800	WHILE SLAVEQ.LENGTH = 0 DO ZYQPASSIVATE;
03810	ACTIVATE C.SUC AFTER C;
03820	C.DEPART;
03830	END ELSE
03840	BEGIN MASTERQ.N := MASTERQ.N+1;
03850	MASTERQ.ZEROS := MASTERQ.ZEROS+1;
03860	END;
03870	COOPT :- P :- SLAVEQ.FIRST;
03880	P.COOPT;
03890	END***CO-OPT***;
03900	
03910	INTEGER PROCEDURE LENGTH;
03920	  LENGTH := SLAVEQ.LENGTH;
03930	
03940	REF(ENTITY)PROCEDURE FIRST;
03950	  FIRST :- SLAVEQ.FIRST;
03960	
03970	REF(ENTITY)PROCEDURE LAST;
03980	  LAST  :- SLAVEQ.LAST;
03990	
04000	MASTERQ :- NEW QUEUE(TITLE);
04010	SLAVEQ  :- NEW QUEUE(TITLE);
04020	MASTERQ.INTO(WAITQQ);
04030	SLAVEQ.INTO(WAITQQ);
04040	SLAVEQ.ZYQSLAVE := TRUE;
04050	END***WAITQ***;
04060	
04070	COMMENT----------------C O N D Q----------------------------;
04080	
04090	QUEUE CLASS CONDQ;
04100	BEGIN BOOLEAN ALL;
04110	
04120	PROCEDURE WAITUNTIL(C); NAME C; BOOLEAN C;
04130	BEGIN REF(ENTITY)E;
04140	IF C THEN
04150	BEGIN ZEROS := ZEROS+1;
04160	N := N+1;
04170	END ELSE
04180	BEGIN
04190	E :- ZYQCURRENT;
04200	E.JOIN(THIS CONDQ);
04210	IF ZYQTRACE THEN NOTE(19,"W'UNTIL IN ",NONE,THIS CONDQ,0.0,0);
04220	L: ZYQPASSIVATE;
04230	IF ALL THEN ACTIVATE E.SUC AFTER E;
04240	IF NOT C THEN GOTO L;
04250	E.DEPART;
04260	IF NOT ALL THEN ACTIVATE ZYQQ.FIRST AFTER E;
04270	IF ZYQTRACE THEN NOTE(20,"LEAVES",NONE,THIS CONDQ,0.0,0);
04280	END;
04290	END***WAITUNTIL***;
04300	
04310	PROCEDURE SIGNAL;
04320	BEGIN
04330	IF ZYQTRACE THEN NOTE(25, "SIGNALS",NONE,THIS CONDQ,0.0,0);
04340	IF LENGTH > 0 THEN ACTIVATE ZYQQ.FIRST DELAY 0.0;
04350	END***SIGNAL***;
04360	
04370	INTO(CONDQQ);
04380	END***CONDQ***;
04390	
04400	COMMENT--------------S N O O P Y-------------------;
04410	
04420	ENTITY CLASS WATCHDOG;
04430	BEGIN REF(CONDQ)Q;
04440	IF ZYQTRACE THEN
04450	BEGIN SYSOUT.SETPOS(25);
04460	OUTTEXT("(ACTIVATES SNOOPY)");
04470	OUTIMAGE;
04480	END;
04490	AGAIN:
04500	Q :- CONDQQ.FIRST;
04510	WHILE Q =/= NONE AND PENDING > 0 DO
04520	BEGIN ACTIVATE Q.ZYQQ.FIRST;
04530	Q :- Q.SUC;
04540	END;
04550	IF PENDING > 0 THEN
04560	BEGIN HOLD(NEXTEV.EVTIME-TIME);
04570	GOTO AGAIN;
04580	END;
04590	PASSIVATE;
04600	REPEAT;
04610	END***WATCHDOG***;
04620	
04630	COMMENT-H O L D,C U R R E N T,P A S S I V A T E,C A N C E L-;
04640	
04650	PROCEDURE HOLD(T); REAL T;
04660	BEGIN IF T < 0.0 THEN T := 0.0;
04670	IF ZYQTRACE THEN NOTE(21, "HOLDS FOR", NONE, NONE, T, 0);
04680	ZYQHOLD(T);
04690	END***HOLD***;
04700	
04710	REF(ENTITY)PROCEDURE CURRENT;
04720	  CURRENT :- ZYQCURRENT QUA ENTITY;
04730	
04740	PROCEDURE PASSIVATE;
04750	BEGIN
04760	IF ZYQTRACE THEN NOTE(22, "PASSIVATES", NONE, NONE, 0.0, 0);
04770	ZYQPASSIVATE;
04780	END***PASSIVATE***;
04790	
04800	PROCEDURE CANCEL(E); REF(ENTITY)E;
04810	BEGIN
04820	IF ZYQTRACE THEN NOTE(23, "CANCELS", E, NONE, 0.0, 0);
04830	ZYQCANCEL(E);
04840	END***ZYQCANCEL***;
04850	
04860	
04870	COMMENT----------T R A C I N G   R O U T I N E S-------------;
04880	
04890	REAL ZYQNOTELASTT;  REF(ENTITY)ZYQNOTELASTE;  BOOLEAN ZYQTRACE;
04900	
04910	PROCEDURE TRACE;
04920	IF NOT ZYQTRACE THEN
04930	BEGIN CLOCKTIME;
04940	BOX("T R A C I N G   C O M M E N C E S");
04950	OUTTEXT("      TIME/ CURRENT     AND ITS ACTION(S)");
04960	OUTIMAGE;  OUTIMAGE;
04970	ZYQTRACE := TRUE;
04980	END***TRACE***;
04990	
05000	PROCEDURE NOTRACE;
05010	IF ZYQTRACE THEN
05020	BEGIN OUTIMAGE;  OUTIMAGE;
05030	CLOCKTIME;
05040	BOX("T R A C I N G   S W I T C H E D   O F F");
05050	ZYQTRACE := FALSE;
05060	ZYQNOTELASTT := -15.0;
05070	ZYQNOTELASTE :- NONE;
05080	END***NOTRACE***;
05090	
05100	PROCEDURE ERROR(N); INTEGER N;;
05110	
05120	PROCEDURE NOTE(INDEX,ACTION,E,L,T1,N);VALUE ACTION;TEXT ACTION;
05130	          INTEGER INDEX, N; REAL T1; REF(ENTITY)E; REF(TAB)L;
05140	BEGIN REAL T; REF(ENTITY)C;
05150	SWITCH MESSAGE := M1, M2, M3, M4, M5, M6, M7, M8, M9,
05160	                  M10,M11,M12,M13,M14,M15,M16,M17,M18,
05170	                  M19,M20,M21,M22,M23,M24,M25,M26,M27;
05180	T := TIME;
05190	C :- CURRENT;
05200	IF (ABS(T)-ZYQNOTELASTT) > 0.0005 THEN
05210	BEGIN ZYQNOTELASTT := T;
05220	PRINTREAL(T);
05230	END;
05240	IF ZYQNOTELASTE =/= C THEN
05250	BEGIN SYSOUT.SETPOS(12);
05260	ZYQNOTELASTE :- C;
05270	OUTTEXT(C.TITLE);
05280	END;
05290	
05300	SYSOUT.SETPOS(25);
05310	OUTTEXT(ACTION);
05320	SYSOUT.SETPOS(36);
05330	GOTO MESSAGE(INDEX);
05340	
05350	M1:     COMMENT E.COOPT;
05360	        IF E == ZYQCURRENT THEN OUTTEXT(" ITSELF ") ELSE OUTTEXT(E.TITLE);
05370	        IF L =/= NONE THEN
05380	        BEGIN OUTTEXT(" FROM ");
05390	          L.SHORTPRINT;
05400	        END;
05410	        GOTO EXIT;
05420	
05430	M2:     COMMENT E.SCHEDULE(T);
05440	        OUTTEXT(E.TITLE);
05450	        IF T1 <= 0.0 THEN OUTTEXT(" NOW") ELSE
05460	        BEGIN OUTTEXT(" AT ");
05470	          PRINTREAL(T+T1);
05480	        END;
05490	        GOTO EXIT;
05500	
05510	M3:     COMMENT TERMINATES;
05520	        GOTO EXIT;
05530	
05540	M4:     COMMENT RES.ACQUIRE - BLOCKED;
05550	M5:     COMMENT RES.ACQUIRE - SEIZES;
05560	M6:     COMMENT RES.RELEASE - RELEASES;
05570	M7:     COMMENT BIN.TAKE    - BLOCKED;
05580	M8:     COMMENT BIN.TAKE    - SEIZES;
05590	M9:     COMMENT BIN.SEND    - RELEASES;
05600	M10:    COMMENT RES.PREEMPT - BLOCKED;
05610	M11:    COMMENT RES.PREEMPT - SEIZES;
05620	M12:    COMMENT RES.PREEMPT - VICTIMISES;
05630	M13:    COMMENT RES.PREEMPT - RESUMES;
05640	        OUTINT(N, 6);
05650	        IF INDEX = 12 THEN
05660	        BEGIN
05670	          OUTTEXT(" FROM ");
05680	          OUTTEXT(E.TITLE);
05690	          GOTO EXIT;
05700	        END ELSE
05710	        IF INDEX = 6 OR INDEX = 9 THEN OUTTEXT(" TO ")  ELSE
05720	        IF INDEX =11 THEN OUTTEXT(" FROM") ELSE OUTTEXT(" OF ");
05730	        L.SHORTPRINT;
05740	        GOTO EXIT;
05750	
05760	M14:    COMMENT Q.WAIT;
05770	        OUTTEXT(" IN ");
05780	        L.SHORTPRINT;
05790	        GOTO EXIT;
05800	
05810	M15:    COMMENT Q.FIND      - BLOCKED;
05820	        OUTTEXT(E.TITLE);
05830	        OUTTEXT(" IN ");
05840	        L.SHORTPRINT;
05850	        GOTO EXIT;
05860	
05870	M16:    COMMENT Q.FIND      - FINDS;
05880	        OUTTEXT(" IN " );
05890	        L.SHORTPRINT;
05900	        GOTO EXIT;
05910	
05920	M17:    COMMENT Q.COOPT     - BLOCKED;
05930	        OUTTEXT(" IN ");
05940	        L.SHORTPRINT;
05950	        GOTO EXIT;
05960	
05970	M18:    COMMENT Q.COOPT     - COOPTS;
05980	        OUTTEXT(E.TITLE);;
05990	        OUTTEXT(" FROM ");
06000	        L.SHORTPRINT;
06010	        GOTO EXIT;
06020	
06030	M19:    COMMENT Q.WAITUNTIL - WAITS;
06040	M20:    COMMENT Q.WAITUNTIL - LEAVES;
06050	M25:    COMMENT Q.SIGNAL;
06060	        L.SHORTPRINT;
06070	        GOTO EXIT;
06080	
06090	M21:    COMMENT HOLDS;
06100	        PRINTREAL(T1);
06110	        OUTTEXT(", UNTIL ");
06120	        PRINTREAL(T+T1);
06130	        GOTO EXIT;
06140	
06150	M22:    COMMENT PASSIVATE;
06160	        GOTO EXIT;
06170	
06180	M23:    COMMENT CANCEL(E);
06190	        IF E == NONE THEN OUTTEXT(" NONE!") ELSE OUTTEXT(E.TITLE);
06200	        GOTO EXIT;
06210	
06220	M24:    COMMENT E.INTERRUPT(N);
06230	        OUTTEXT(E.TITLE);
06240	        OUTTEXT(", WITH N = ");
06250	        OUTINT(N,6);
06260	        GOTO EXIT;
06270	
06280	M26:
06290	M27:
06300	EXIT:   OUTIMAGE;
06310	END***NOTE***;
06320	
06330	
06340	COMMENT---------S N A P P I N G   R O U T I N E S------------;
06350	
06360	PROCEDURE REPORT;
06370	BEGIN REF(REPORTQ)R;
06380	EJECT(1);
06390	CLOCKTIME;
06400	BOX("R E P O R T");
06410	FOR R:-DISTQ,EMPQ,ACCUMQ,COUNTQ,TALLYQ,HISTOQ,RESQ,BINQ,QUEUEQ,
06420	       WAITQQ,CONDQQ DO
06430	IF NOT R.EMPTY THEN
06440	BEGIN EJECT(LINE+2);
06450	R.REPORT;
06460	END;
06470	END***REPORT***;
06480	
06490	PROCEDURE RESET;
06500	BEGIN REF(REPORTQ)R;
06510	EJECT(1);
06520	CLOCKTIME;
06530	BOX("A L L   Q U A N T I T I E S   R E S E T");
06540	FOR R:-DISTQ,EMPQ,ACCUMQ,TALLYQ,HISTOQ,COUNTQ,RESQ,BINQ,QUEUEQ,
06550	       WAITQQ,CONDQQ DO
06560	IF NOT R.EMPTY THEN R.RESET;
06570	END***RESET***;
06580	
06590	PROCEDURE SNAPEVENTLIST;
06600	BEGIN REF(PROCESS)P;  REF(ENTITY)E;
06610	REAL R; TEXT T; INTEGER K;
06620	OUTIMAGE; OUTIMAGE;
06630	CLOCKTIME;
06640	BOX("E V E N T   L I S T");
06650	OUTTEXT(" NO.     EVENT TIME     ENTITY  COMPLETED CYCLES");
06660	OUTIMAGE;  OUTIMAGE;
06670	P:- CURRENT;
06680	WHILE P =/= NONE DO
06690	BEGIN K := K+1;
06700	OUTINT(K, 4);
06710	SYSOUT.SETPOS(6);
06720	OUTFIX(P.EVTIME, 4, 14);
06730	SYSOUT.SETPOS(25);
06740	IF P IN ENTITY THEN
06750	BEGIN E :- P QUA ENTITY;
06760	OUTTEXT(E.TITLE);
06770	SYSOUT.SETPOS(48);
06780	OUTINT(E.CYCLE, 5);
06790	END ELSE OUTTEXT("****NON-ENTITY OBJECT IN EVENT LIST");
06800	OUTIMAGE;
06810	P :- P.NEXTEV;
06820	END;
06830	EJECT(LINE+2);
06840	OUTIMAGE;
06850	END***SNAP EVENT LIST***;
06860	
06870	PROCEDURE SNAPQUEUES;
06880	BEGIN REF(QUEUE)Q;
06890	BOX("L I S T   O F   A L L   Q U E U E S");
06900	FOR Q :- QUEUEQ.FIRST, CONDQQ.FIRST, WAITQQ.FIRST DO
06910	BEGIN
06920	WHILE Q =/= NONE DO
06930	BEGIN Q.LISTMEMBERS;
06940	OUTIMAGE;
06950	Q :- Q.SUC;
06960	END;
06970	EJECT(LINE+2);
06980	OUTIMAGE;
06990	END;
07000	END***SNAP ALL QUEUES***;
07010	
07020	PROCEDURE SNAPPASSIVE;
07030	BEGIN REF(QUEUE)Q; INTEGER K; REF(ENTITY)E;
07040	EJECT(1);
07050	BOX("L I S T   O F   P A S S I V E   O B J E C T S");
07060	FOR Q :- QUEUEQ.FIRST, CONDQQ.FIRST, WAITQQ.FIRST DO
07070	BEGIN
07080	WHILE Q =/= NONE DO
07090	BEGIN Q.SHORTPRINT;
07100	OUTIMAGE;
07110	OUTTEXT(" NO. OBJECT               TIME OF ENTRY/PRIORITY");
07120	E :- Q.FIRST;  K := 0;
07130	WHILE E =/= NONE DO
07140	BEGIN K := K+1;
07150	OUTINT(K, 4);
07160	SYSOUT.SETPOS(6);
07170	OUTTEXT(E.TITLE);
07180	SYSOUT.SETPOS(26);
07190	OUTFIX(E.TIMEIN, 4, 14);
07200	OUTINT(E.PRIORITY, 9);
07210	OUTIMAGE;
07220	E :- E.SUC;
07230	END;
07240	OUTIMAGE;  OUTIMAGE;
07250	Q :- Q.SUC;
07260	END;
07270	EJECT(LINE+2);
07280	OUTIMAGE;
07290	END;
07300	END***PRINT PASSIVE***;
07310	
07320	PROCEDURE POSTMORTEM;
07330	BEGIN BOX("P O S T M O R T E M");
07340	SNAPEVENTLIST;
07350	SNAPQUEUES;
07360	END***POSTMORTEM***;
07370	
07380	ENTITY CLASS MAINPROGRAM;
07390	BEGIN ZYQCANCEL(NEXTEV);
07400	L:  DETACH; GOTO L;
07410	END***MAIN PROGRAM***;
07420	
07430	LINK CLASS ZYQENTTITLE(T); TEXT T;
07440	BEGIN INTEGER N, L;
07450	FOLLOW(ZYQENTNAMES);
07460	L := T.LENGTH;
07470	N := 1;
07480	END***ZYQENTTITLE***;
07490	
07500	REF(HEAD)ZYQENTNAMES;
07510	
07520	REF(WATCHDOG)SNOOPY;
07530	REF(MAINPROGRAM)DEMOS, MAIN;
07540	INTEGER ZYQPSERNO, PENDING;
07550	REAL NOW;
07560	REAL SIMPERIOD;
07570	REF(REPORTQ)RESQ, BINQ, QUEUEQ, CONDQQ, WAITQQ;
07580	TEXT RESHEADING, BINHEADING, QHEADING, ZYQSTARS;
07590	
07600	NOW := -15.0;
07610	ZYQNOTELASTT := -15.0;
07620	ZYQSTARS :- SYSOUT.IMAGE.SUB(13, 1);
07630	ZYQENTNAMES :- NEW HEAD;
07640	RESHEADING:-COPY("/ LIM/ MIN/ NOW/  % USAGE/ AV. WAIT/QMAX");
07650	BINHEADING:-COPY("/INIT/ MAX/ NOW/ AV. FREE/ AV. WAIT/QMAX");
07660	QHEADING  :-COPY("/ QMAX/ QNOW/ Q AVERAGE/ZEROS/  AV. WAIT");
07670	RESQ  :-NEW REPORTQ("R E S O U R C E S",HEADINGRTN,RESHEADING);
07680	BINQ  :-NEW REPORTQ("B I N S",HEADINGRTN,BINHEADING);
07690	QUEUEQ:-NEW REPORTQ("Q U E U E S",HEADINGRTN,QHEADING);
07700	CONDQQ:-NEW REPORTQ("C O N D I T I O N   Q U E U E S",HEADINGRTN,
07710	                                                      QHEADING);
07720	WAITQQ:-NEW REPORTQ("W A I T   Q U E U E S",HEADINGRTN,QHEADING);
07730	MAIN  :- DEMOS :- NEW MAINPROGRAM("DEMOS");
07740	ACTIVATE DEMOS;
07750	INNER;
07760	ZYQHOLD(0.0);
07770	ABORT:;
07780	REPORT;
07790	END***DEMOS***;