         SYSTEM   UTS
PM       EQU      %
PMONOFF EQU 1
P        EQU      PMONOFF
         DO       P
         DEF      ACTIVATE
         DEF      CURNTIM
         DEF      ISWAP%MEAS1
         DEF      ISWAP%MEAS2
         DEF      OSWAP%MEAS
         DEF      PM
         DEF      RDMSGSIZ
         DEF      READREQ
         DEF      T:DSTRB
         FIN
         DEF      T:SYSTEMLOAD
         DO       P
         DEF      WTMSGSIZ
         REF      C:PROCN           NUMBER OF PROC TO MONITOR
*
         REF      J:JIT
*
         REF      BGNPMPRC
         REF      C:CIT
         REF      C:CITI
         REF      C:COS
         REF      C:ETM
         REF      C:RT90
         REF      C:SC
         REF      C:SCI
         REF      C:SIT
         REF      C:SRT
         REF      C:ST
         REF      C:STT
         REF      C:TIC
         REF      C:TINC
         REF      CH:DC
         REF      CH:DI1            IN SWAP PROC & JIT
         REF      CH:DI2            IN SWAP REST OF USER
         REF      CH:DI3
         REF      CH:DIT
         REF      CH:DLI
         REF      CH:DLO
         REF      CH:DOT            OUT SWAP TIME
         REF      CH:DRT
         REF      CH:DT
         REF      CH:DTT
         REF      CH:SWAPT
         REF      CITHEN
         REF      COCLN
         SREF     COCOC
         REF      DRTHEN
         REF      DTBLWSZ
         REF      ENDPMPRC
         SREF     EOMTIME
         REF      J:DELTAT
         REF      J:OVHTIM
         REF      J:PTIME
         REF      J:UTIME
         REF      J:T
         REF      J:TIC
         SREF     LB:UN
         REF      M:UC
         REF      M16
         REF      M8
         REF      UB:ACP
         REF      UB:DB
         REF      RT90THEN
         FIN
         REF      S:CUN
         DO1      P
         REF      SL:SQUAN
         DO       P
         REF      UB:APR
         REF      UB:ASP
         FIN
         REF      UH:FLG
         REF      UB:FL
         REF      SB:HQ
         REF      J:IDELTAT
         PAGE
         DO       P
************************************************************************
*                                                                      *
*                 DATA                                                 *
*                                                                      *
************************************************************************
DIST%TBL%SIZ      ;                 HALF WORD SIZE OF DISTRIBUTION
         EQU      16                TABLES
FILTSIZ  EQU      13
FILTVEC  EQU      %                 VECTOR OF ADDRESSES OF FILTERS
         GEN,1,31 1,HA(FILTR1)
         GEN,1,31 1,HA(FILTR2)
         GEN,1,31 1,HA(FILTR3)
         BOUND    4
FILTR1   EQU      %
         DATA,2   1,2,5,10,20,50,100,200,500
         DATA,2   1000,2000,5000,10000
         DATA,2   32767
*
         BOUND    4
FILTR2   EQU      %
         DATA,2   5,10,15,20,25,30,35
         DATA,2   40,45,50,55,60,65
         DATA,2   32767
*
         BOUND    4
FILTR3   EQU      %
         DATA,2   1,2,3,4,5,6,7,8
         DATA,2   9,10,11,12,13
         DATA,2   32767
         BOUND    4
MAX#FILT EQU      3
USERINDX EQU      ENDPMPRC+1
         PAGE                                                           01759000
*
CURNTIM  EQU      %                 COMPUTE CURRENT TIME
         REF      C:CTUN
         LW,1     C:CTUN
         SW,1     C:TINC
         AW,1     C:TIC
         B        *0                RETURN
*
T:DSTRBMS EQU     %
         SLS,1    1                 SCALE FACTOR = 1/2
T:DSTRB  EQU      %
         PUSH     5,0
         LW,3     0,5               SCALE & FILTER POINTER
         DH,1     3                 DIV BY SCALE
         CI,1     32766             SET
         BLE      %+2                A
         LI,1     32766               CAP
         AND,3    M8                EXTRACT FILTER POINTER
         AI,3     -MAX#FILT
         BGZ      SWAPEXIT          TOO BIG - FLUSH
         LW,4     FILTVEC-1+MAX#FILT,3  FILTER ADDRESS
DST10    CH,1     0,4               CHK FILTER VALUE
         BL       DST20
         BIR,4    DST10             TRY AGAIN
DST20    SW,4     FILTVEC-1+MAX#FILT,3  FILTER POSITION
         AI,5     1                 HALFWORD
         SLS,5    1                  ADDRESS
         AW,5     4                   OF BUCKET
         MTH,1    0,5               COUNT IT  UP
         SLS,2    4                 ALIDN
         AW,5     2                 PROC OR USER TABLE
         AI,2     0                 SKIP
         BGZ      SWAPEXIT           IF
         LI,5     0                   PROC OR USER
SWAPEXIT PULL     5,0
         B        0,4
         PAGE                                                           01142000
PMSCA    RES      0
         DEF      PMSCA
*                                                                       01394000
*        INPUT    R1 = USER #
*        OUTPUT   R2 = PROC # OR USER INDEX
*                 INDX = HALF WORD OFFSET TO PROC OR USER TABLE
*
         LW,1     S:CUN
GETINDX  EQU      %
         LH,0     UH:FLG,1          GET FLAGS FOR THIS USER
         CI,0     TIC+DIC           TEL OR DELTA
         BAZ      IDX15
         CI,0     DIC
         BANZ     IDX20-1
         LB,2     UB:ACP,1
         B        IDX20
IDX15    EQU      %
         LB,2     UB:ASP,1          GET SPECIAL PROCESSOR FLAG
         BNEZ     IDX20             SET, FINISH UP
         LB,2     UB:APR,1          GET COMMON PROCESSOR INDEX
         BNEZ     IDX20             SET, FINISH UP
         LI,2     USERINDX          NOT A PROCESSOR, USE USER INDEX
         AI,4     0
         BGE      0,4               RETURN IF NOT GETIN
IDX23    CW,2     C:PROCN           IS THIS THE PROC TO BE MONITORED
         BNE      IDX24             NO
         LI,2     1                 SET TO SECOND DISTRIB TABLE
         B        0,4               AND RETURN
         LB,2     UB:DB,1
IDX20    EQU      %
         AI,4     0                 CHECK FOR GETIN
         BLZ      IDX23             YES
         AI,2     -BGNPMPRC+1       BIAS FOR PROCS BEING MEASURED
         BLEZ     IDX24             DONT MEASURE THIS ONE
*
         CI,2     ENDPMPRC          BIGGEST PROC # TO BE MEASURED
         BLE      IDX25             OUT IF IN RANGE
IDX24    EQU      %
         LI,2     0
IDX25    EQU      %
         B        0,4               RETURN
         PAGE
*
*        GET INDEX OF PROCESSOR TO BE MONITORED WITH DISTRIBUTIONS
*
GETIN    LW,1     S:CUN             GET USER NUMBER
GETIN1   OR,4     Y8                SET FLAG
         REF      Y8
         B        GETINDX           FIN INDEX
         FIN
         PAGE
*        THIS ROUTINE IS INVOKED PERIODICALLY BY THE CLOCK ROUTINE AND
*        BY THE CAL1,9 X'C' WHICH RETURNS SYSTEM LOAD AS OUTPUT
*
T:SYSTEMLOAD EQU  %
         DO       P
         LCW,1    C:CIT             COMPUTE # OF INTERACTIONS
         XW,1     CITHEN            IN LAST TIME PERIOD
         SW,1     CITHEN            AND SAVE CURRENT TOTAL
         BLEZ     SYSLD75           EXIT IF NONE
*
         MI,1     29                90%
         SLS,1    -5                OF INTERACTIONS
*
         LI,2     0
         LI,3     -1
*                                   SUM THE INTERACTIONS DISTRIBUTED
SYSLD10  EQU      %                 BY TIME TO FIND THE 90% POINT
         AI,3     1
         AH,2     CH:DRT+1,3
         SH,2     DRTHEN,3
         CW,2     1
         BGE      SYSLD40
*
         CI,3     DIST%TBL%SIZ-3
         BL       SYSLD10
*
*
SYSLD40  EQU      %
         LI,4     X'FF'
         AND,4    CH:DRT
         AW,3     FILTVEC-1,4
         LH,0     0,3               GET VALUE
*
         XW,0     RT90THEN          COMPUTE AVERAGE 90% POINT
         AW,0     RT90THEN          OVER LAST INTERVAL
         SLS,0    -1
*
         STW,0    C:RT90            SAVE 90% POINT
*
         LI,3     DTBLWSZ
SYSLD70  EQU      %                 SAVE CURRENT RESPONSE
         LW,0     CH:DRT,3          TIME DISTRIBUTIONS
         STW,0    DRTHEN-1,3
         BDR,3    SYSLD70
*
*
*                                   COMPUTE EXECUTION TIME MULTIPLIER
*
SYSLD75  EQU      %
         LW,6     C:ETM
         LI,5     1                 START AT TOP STATE
SYSLD77  LB,2     SB:HQ,5           GET HEAD OF STATE
         BEZ      SYSLD76           NONE, EMPTY
         AI,6     1                 COUNT HIM
         LB,2     UB:FL,2           FLINK ALONG
         BNEZ     %-2               GOT ANOTHER
SYSLD76  AI,5     1                 NEXT STATE
         CI,5     SEXU              CHECK FOR END
         BLE      SYSLD77           CONTINUE
         SLS,6    -1                DIVIDE BY TWO
         AI,6     0
         BNE      %+2               ONE IS
         LI,6     1                  THE MINIMUM ETMF
         STW,6    C:ETM             PUT IT AWAY
         REF      SEXU
         FIN
*
         B        *11
         PAGE                                                           01103000
         DO       P
*
*
*        R3   -   START TIME FOR SWAP I/O
*
OSWAP%MEAS EQU %
         LI,5     CH:DOT            OUT SWAP TIME DISTRB TABLE
         MTW,1    C:COS             BUMP OUTSWAP COUNT
         B        SWAPTIME
*
ISWAP%MEAS1 EQU %
         LI,5     CH:DI1            INSWAP TIME FOR PROCS & JIT
         B        SWAPTIME
*
ISWAP%MEAS2 EQU %
         LI,5     CH:DI2            INSWAP TIME FOR REST OF USER
*
         LI,15    CH:DI3
SWAPTIME EQU %
         PUSH     5,0
*
         BAL,0    CURNTIM           GET CURRENT TIME
         LH,0     CH:SWAPT          GET TIME AT END OF PREVIOUS SWAP
         STH,1    CH:SWAPT          SAVE TIME AT END OF THIS SWAP
*
         SW,1     3                 COMPUTE SWAP TIME
         AND,1    M16
*
         BAL,4    T:DSTRB           DISTRIBUTE IN OR OUT SWAP TIME
*
         CI,15    CH:DI3            USER IN SWAP COMPLETE
         BNE      SWAPEXIT          BRANCH IF NO
*
         LI,5     CH:DI3
         LH,1     CH:SWAPT          COMPUTE TIME FROM END OF
         SW,1     0                 PROC&JIT IN SWAP TO END OF USER IN SWAP
         AND,1    M16
         B        T:DSTRB+2
         PAGE                                                           01812000
*
*        R2  -    LINE #
*        R10  -   ACTUAL RECORD SIZE
*
RDMSGSIZ EQU      %
         PUSH     5,0
         LW,3     8                 ARS
         LI,5     CH:DLI            COUNT UP APPROPRIATE BUCJKET
         B        RDM1
*
*        R2  -    LINE #
*       R5  -    COUNT OF OUTPUT CHARS WHEN OUTPUT REQUEST WAS MADE
*        R7  -    CURRENT COUNT OF OUTPUT CHARACTERS
*
WTMSGSIZ EQU      %
         PUSH     5,0
         LB,3     3                 KEEP TRACK OF WHAT
         SW,5     3                 DIDN'T GET TO COCOC YET
         LB,3     COCOC,2           CURRENT OUTPUT CHAR COUNT
         SW,3     5                 COMPUTE OUTPUT MESSAGE LENGTH
         LI,4     1                 SET TURNAROUND TIME
         LH,1     J:TIC,4
         BNEZ     %+5
         BAL,0    CURNTIM
         SLS,1    -5
         SH,1     M:UC+9
         STH,1    J:TIC,4
         LI,5     CH:DLO            OUTPUT LENGTH
RDM1     RES      0
         LB,1     LB:UN,2           GET USER #
         BAL,4    GETIN1            GET INDEX, USER NO IN R1
         LW,1     3                 VALUE TO R1 FOR T:DSTRB
         BAL,4    T:DSTRB
         MTH,1    0,5               COUNT UP PROC OR USER DISTIRRIB
         B        SWAPEXIT
*
         PAGE                                                           01065000
ACTIVATE EQU      %
         CI,15    INTERACT          CHECK FOR INTERACTIVE
         BAZ      0,6               NO
         AI,15    -INTERACT         RESET INTERACTIVE FLAG
         STH,15   UH:FLG,4          PUT AWAY
         LC       J:JIT             CHECK FOR
         BCR,8+4  0,6               ONLINE
INTERACT EQU      X'20'             FLAG BIT FOR INTERACTIVE
         LW,2     M:UC+COCLN        LINE NO
         AND,2    M8
         BAL,0    CURNTIM           GET CURRENT TIME
         SH,1     EOMTIME,2         RESPONSE TIME
         STH,1    J:TIC
         AH,1     EOMTIME,2         RESTORE CURRENT TIME
         SH,1     J:TIC             WITH ALL SIGNIFICANCE
         SLS,1    -5
         STH,1    M:UC+9
ACTOUT   B        0,6
*
*
*
*
COMPTIM  EQU      %
         AW,1     J:DELTAT
         SW,1     J:IDELTAT
         AW,1     J:OVHTIM
         AW,1     J:PTIME
         AW,1     J:PTIME+1
         AW,1     J:UTIME
         AW,1     J:UTIME+1
         B        0,4
         PAGE
*
READREQ  EQU      %
*
*                 -----------------------------------------
*        J:TIC  |    RESPONSE TIME    | TURNAROUND OR 0     |  IN
*                 -----------------------------------------
*        J:T    | PREV READ COMP TIME | PREV READ CURN TIME |  IN
*                 -----------------------------------------
*
*                 -----------------------------------------
*        J:TIC  |                     0                     |  OUT
*                 -----------------------------------------
*        J:T    | CURN READ COMP TIME | CURN READ CURN TIME |  OUT
*                 -----------------------------------------
*
         PUSH     5,0
         BAL,0    CURNTIM
         SLD,0    27
         XW,0     J:TIC
         LH,1     0                 GET RESPONSE TIME
         BEZ      PM20              FIRST TIME IN - INITIALIZE ONLY
         AND,1    M16
         AWM,1    C:SRT
         LI,5     CH:DRT
         BAL,4    T:DSTRBMS
         LW,5     0
         BAL,4    GETIN             GET INDEX FOR CURRENT USER
         AND,5    M16
         LW,1     5
         BNEZ     %+4
         LW,1     J:TIC             NO, IT = CURNTIM - EOMTIME
         SH,1     M:UC+9
         AND,1    M16
         SLS,1    5
         AWM,1    C:STT
         AI,2     0
         BE       %+2
         AWM,1    C:STT,2
         LI,5     CH:DTT
         BAL,4    T:DSTRB
         MTH,1    0,5
         LH,1     M:UC+9
         SW,1     J:T               =EOMTIME - READREQ TIME
         AND,1    M16
         SLS,1    5
         AWM,1    C:ST
         AI,2     0
         BE       %+2
         AWM,1    C:ST,2
         LI,5     CH:DT
         BAL,4    T:DSTRB
         MTH,1    0,5
         LW,1     J:TIC             INTERACTION TIME
         SW,1     J:T               =READ-PREV READ
         AND,1    M16
         SLS,1    5
         AWM,1    C:SIT
         LI,5     CH:DIT
         BAL,4    T:DSTRB
         LCH,1    J:T               COMPUTE TIME
         BAL,4    COMPTIM
         AND,1    M16               SET BY READREQ
         CW,1     SL:SQUAN
         BGE      %+3
         AWM,1    C:SCI
         MTW,1    C:CITI
         AWM,1    C:SC
         AI,2     0
         BE       %+2
         AWM,1    C:SC,2
         MTW,1    C:CIT
         LI,5     CH:DC
         BAL,4    T:DSTRBMS
         MTH,1    0,5
PM20     EQU      %
         LW,1     J:TIC             CURN TIME
         STW,1    J:T
         LI,1     0
         STW,1    J:TIC
         BAL,4    COMPTIM
         STH,1    J:T
         B        SWAPEXIT
         FIN
         END

