From:	SMTP%"turion@research.ptt.nl" 21-MAR-1994 17:40:01.34
To:	EVERHART
CC:	
Subj:	part 7 status tool

X-Newsgroups: comp.os.vms
From: turion_s@dnlts0research.ptt.nl. (Paul Turion)
Subject: part 7 status tool
Message-ID: <1994Mar21.144337.1301@news.research.ptt.nl>
Sender: turion_s@research.ptt.nl (Paul Turion)
Nntp-Posting-Host: dnlts0.research.ptt.nl
Reply-To: turion@research.ptt.nl
Organization: PTT Research
X-Newsreader: mxrn 6.18-4
Date: Mon, 21 Mar 1994 14:43:37 GMT
Lines: 464
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET


-- 
 ------- --------------------  			Paul Turion 
| p t t |  r e s e a r c h   |			The Netherlands
|      _|                    | 			e-mail address
|    _|_|   .  .  .  .  .    |			P.Turion@research.ptt.nl
|___|_|      
My interest is in the future because
I am going to spend the rest of my life there.
-+-+-+-+-+-+-+-+ START OF PART 7 -+-+-+-+-+-+-+-+
X                        ;R0-R4 are available
X`032
X;---
X; See if we are supposed to abort
X;---
X    TSTB    STOPPING
X    BEQL    10$
X.IF    NDF,VMS_V5
X    MOVAL    @#EXE$AL_TQENOREPT,R5
X.IFF
X    MOVL    G`094EXE$AR_TQENOREPT,R5
X.ENDC
X    CLRB    RUNNING
X    RSB
X10$:
X`032
X    CLRL    R2                ;Initialize the run count=0
X;+ ---
X; Check the run queues for the number of processes in 'COM' state
X;- ---
X    CLRL    R1                ;Initialize summary word pos=0
X`032
X.IF    NDF,VMS_V5
X    DSBINT    #IPL$_SYNCH
X.IFF
X    LOCK    SCHED
X.ENDC
X    BICL3    PRIORITY_MASK,@#SCH$GL_Comqs,R4 ;Get masked queues
XFind_Comq:                    ;Find a run queue with entries
X    SUBL3    R1,#32,R0            ;Calculate #bits left (32-R1)
X    FFS    R1,R0,R4,R1            ;Look for an active queue
X    BEQL    Ncomo                ;None: look for procs waiting
X                        ;    for inswap
X    MOVAQ    @#SCH$AQ_Comh`091R1`093,R0        ;Got one: get its queue heade
Vr
X    MOVL    R0,R3                ;Save terminating address
X`032
X10$:    MOVL    (R0),R0                ;Get the next process in the q
X    CMPL    R0,R3                ;End of queue?
X    BEQL    20$                ;Yes: look for next queue
X    INCL    R2                ;No: count this process
X    BRB    10$                ;and try the next one
X`032
X20$:    INCL    R1                ;Queue done, look for next one
X    BRB    Find_Comq
X`032
X;+ ---
X; Check the COMO queues for the number of processes in 'COM' state (outswap)
X;- ---
XNcomo:    CLRL    R1                ;Initialize summary word pos=0
X    BICL3    PRIORITY_MASK,@#SCH$GL_Comoqs,R4 ;Get masked queues
XFind_Comoq:                    ;Find a run queue with entries
X    SUBL3    R1,#32,R0            ;Calculate #bits left (32-R1)
X    FFS    R1,R0,R4,R1            ;Look for an active queue
X    BEQL    Nwait                ;None: look for procs waiting
X                        ;    for resources
X    MOVAQ    @#SCH$AQ_Comoh`091R1`093,R0        ;Got one: get its queue head
Ver
X    MOVL    R0,R3                ;Save terminating address
X`032
X10$:    MOVL    (R0),R0                ;Get the next process in the q
X    CMPL    R0,R3                ;End of queue?
X    BEQL    20$                ;Yes: look for next queue
X    INCL    R2                ;No: count this process
X    BRB    10$                ;and try the next one
X`032
X20$:    INCL    R1                ;Queue done, look for next one
X    BRB    Find_Comoq
X`032
X;+ ---
X; Count processes in collided page wait
X;- ---
XNwait:
X    MOVAQ    @#SCH$GQ_Colpgwq,R0        ;Get the collided page wait q
X`032
X10$:    MOVL    (R0),R0                ;Get the next process in the q
X    CMPL    R0,#SCH$GQ_Colpgwq        ;End of queue?
X    BEQL    Npfw                ;Yes: look at page fault waits
X    INCL    R2                ;No: count this process
X    BRB    10$                ;and try the next one
X`032
X;+ ---
X; Count processes in page fault wait
X;- ---
XNpfw:
X    MOVAQ    @#SCH$GQ_PfwQ,R0        ;Get the page fault wait q
X`032
X10$:    MOVL    (R0),R0                ;Get the next process in the q
X    CMPL    R0,#SCH$GQ_Pfwq            ;End of queue?
X    BEQL    Nfpw                ;Yes: look at free page waits
X    INCL    R2                ;No: count this process
X    BRB    10$                ;and try the next one
X`032
X;+ ---
X; Count processes in free page wait
X;- ---
XNfpw:
X    MOVAQ    @#SCH$GQ_FpgwQ,R0        ;Get the free page wait q
X`032
X10$:    MOVL    (R0),R0                ;Get the next process in the q
X    CMPL    R0,#SCH$GQ_Fpgwq        ;End of queue?
X    BEQL    Count_Done            ;Yes: all done
X    INCL    R2                ;No: count this process
X    BRB    10$                ;and try the next one
X`032
XCount_Done:
X.IF    NDF,VMS_V5
X    ENBINT
X.IFF
X    UNLOCK    SCHED
X.ENDC
X.IF    NDF,VMS_V5
X;
X;   Adjust for the NULL job, which might be missing if the mask
X;   exclused the priority 0 queue.
X;
X    BBS    #31,PRIORITY_MASK,10$
X    DECL    R2                ; SUBTRACT THE NULL JOB
X10$:
X;
X;   Adjust for the CURrent job if the priority is high enough.
X;
X    BBS    @#SCH$GB_PRI,PRIORITY_MASK,20$
X    INCL    R2                ; ADD THE CURRENT JOB
X20$:
X.ENDC
X.IF    NDF,VMS_V5
X    MOVL    G`094SCH$GB_PRI,R3
X.IFF
X;
X;   Count done, now scan through each CPU. Store the LOWEST priority
X;   found and the number of executing CPUs.
X;
X    CLRL    R3                ; Lowest priority
X    CLRL    R4                ; Number of CPUs active
X    CLRL    R1                ; Current CPU index
X11$:    SUBL3    R1,#32,R0            ;Calculate #bits left (32-R1)
X    FFS    R1,R0,@#SMP$GL_ACTIVE_CPUS,R1    ;Look for an active CPU
X    BEQL    35$
X15$:    MOVL    g`094SMP$GL_CPU_DATA`091R1`093,R0    ; Get the CPU database
X    BEQL    30$                ; This CPU doesn't exist
X    INCL    R4                ; Seen one more CPU
X    CMPL    CPU$L_CURPCB(R0),@#SCH$AR_NULLPCB ; Running 'the null job'?
X    BEQL    20$
X    MOVZBL    CPU$B_CUR_PRI(R0),-(SP)
X    BBS    (SP)+,PRIORITY_MASK,20$        ; but priority is 'masked'
X    INCL    R2                ; CPU is active.
X20$:    CMPB    CPU$B_CUR_PRI(R0),R3        ; Store the lowest executing pri
Vority
X    BLEQU    30$
X    MOVB    CPU$B_CUR_PRI(R0),R3
X30$:    INCL    R1
X    BRB    11$                ; Check for all 32 CPUs.
X35$:
X.ENDC
X`032
X;+ ---
X; Count done, calculate the load ave.
X;- ---
X    CVTLF    R2,R2                ;Float the count of processes
X.IF    DF,VMS_V5
X    CVTLF    R4,R4                ;Float the count of CPUs
X    DIVF2    R4,R2                ;Load is Processes/CPUs.
X.ENDC
X; 1 min. load ave.
X    MULF3    R2,F11,R0            ;La=OldLa*F+NewLa*(1-F)
X    MULF3    M1,F1,R1
X    ADDF3    R0,R1,M1
X; 5 min. load ave.
X    MULF3    R2,F12,R0
X    MULF3    M5,F2,R1
X    ADDF3    R0,R1,M5
X; 15 min. load ave.
X    MULF3    R2,F13,R0
X    MULF3    M15,F3,R1
X    ADDF3    R0,R1,M15
X`032
X    CMPB    R3,#255                ; NULL JOB
X    BNEQ    40$
X    MOVB    #32,R3                ; TREAT AS PRIORITY 0
X40$:    SUBB3    R3,#32,R2
X    CVTBF    R2,R2
X; 1 min. priority ave.
X    MULF3    R2,F11,R0            ;La=OldLa*F+NewLa*(1-F)
X    MULF3    P1,F1,R1
X    ADDF3    R0,R1,P1
X; 5 min. priority ave.
X    MULF3    R2,F12,R0
X    MULF3    P5,F2,R1
X    ADDF3    R0,R1,P5
X; 15 min. priority ave.
X    MULF3    R2,F13,R0
X    MULF3    P15,F3,R1
X    ADDF3    R0,R1,P15
X`032
X;
X;   Update the disk queue length information
X;
XQUEUE_LEN:
X    CLRL    R2                ; R2 = Sun of queue lengths
X    PUSHR    #`094M<R10,R11>
X    CLRQ    R10                ; Indicate start of I/O d.b.
X10$:    JSB    G`094IOC$SCAN_IODB            ; Get next DDB and UCB into R10
V, R11
X    BLBC    R0,40$                ;  no more, done
X    CMPB    #DC$_DISK,UCB$B_DEVCLASS(R10)    ; Is this controller a disk?
X    BEQL    20$
X    CLRL    R10                ; Go for next controller
X    BRB    10$
X20$:    BBC    #DEV$V_MNT,UCB$L_DEVCHAR(R10),10$ ; Skip if not mounted
X    BITL    #<DEV$M_CDP+DEV$M_SSM>,UCB$L_DEVCHAR2(R10) ; class driver or sha
Vdow set member?
X    BNEQ    10$                ;          if so, skip
X    CVTWL    UCB$W_QLEN(R10),R0        ; Get queue length
X    BGEQ    30$
X    CLRL    R0                ; negative queu length is a temporary conditio
Vn
X30$:    CMPL    R0,R2
X    BLEQ    10$
X    MOVL    R0,R2
X    BRB    10$
X40$:    POPR    #`094M<R10,R11>            ; restore registers
X`032
X    CVTLF    R2,R2                ;Float the count
X; 1 min. queue ave.
X    MULF3    R2,F11,R0            ;La=OldLa*F+NewLa*(1-F)
X    MULF3    Q1,F1,R1
X    ADDF3    R0,R1,Q1
X; 5 min. queue ave.
X    MULF3    R2,F12,R0
X    MULF3    Q5,F2,R1
X    ADDF3    R0,R1,Q5
X; 15 min. queue ave.
X    MULF3    R2,F13,R0
X    MULF3    Q15,F3,R1
X    ADDF3    R0,R1,Q15
X    RSB                    ;Return to clock dispatcher
X`032
X`032
X`032
X    .SBTTL    END OF DRIVER
X;+ ---
X;
X; END OF DRIVER
X;
X;- ---
XLAV_END:                    ;LET DPTAB KNOW THE DRIVER SIZE
X;
X    .END
$ CALL UNPACK LAVDRIVER.MAR;3 1578563214
$ create/nolog 'f'
Xsys$system:sys.stb/sel
$ CALL UNPACK LAVDRIVER.OPT;1 591101241
$ create/nolog 'f'
XFrom:`009DNLTS::COM%"adelman@WARBUCKS.AI.SRI.COM" 23-AUG-1988 18:29
XTo:`009BRAAMS
XSubj:`009Nice software; be a shame if it were to bugcheck.
X
XReceived: From HEARN(MAILER) by HLSDNL50 with Jnet id 2358
X          for BRAAMS@HLSDNL50; Tue, 23 Aug 88 18:30 N
XReceived: by HEARN (Mailer X1.25) id 2213; Tue, 23 Aug 88 17:54:22 MET
XDate:         Tue, 26 Jul 88 23:01:19 PDT
XReply-To:     Kenneth Adelman <Adelman@Warbucks.AI.SRI.COM>
XSender:       Info Vax <INFO-VAX@HEARN>
XFrom:         Kenneth Adelman <adelman@WARBUCKS.AI.SRI.COM>
XSubject:      Nice software; be a shame if it were to bugcheck.
XComments: To: info-vax@kl.sri.com
XTo:           'Johannes Braams' <BRAAMS@HLSDNL50>
X`032
X    Oops. The Load Average driver I posted a few weeks ago had a
Xfatal bug. Fortunately, I fell on my own sword before anyone else
Xreported this to me. Here is a fixed version, which includes the
Xconditionals to run on VMS V4. Add a "VMS_V5=1" line at the top for
XVMS V5.
X`032
X                        Ken
X`032
X`032
X    .TITLE    LAVDRIVER    VAX/VMS Load Average Pseudo Device
X    .IDENT    /Version 4.00/
X    .SBTTL    DOCUMENTATION
X;---------------S-R-I-International-Artificial-Intelligence-Center----------
V-
X;
X;
X; MODULE NAME:
X;
X;    LAVDRIVER
X;
X; PURPOSE:
X;
X;    This is a pseudo device which supplies load average information to
X;    programs wishing to display some indication of system load.
X;
X; KEYWORDS:
X;
X;    Drivers
X;
X; USAGE:
X;
X;    Standard system QIO calls.
X;
X;    The driver is installed via sysgen.  The following is the correct
X;        sysgen command sequence.
X;
X;        SYSGEN>  LOAD LAVDRIVER
X;        SYSGEN>  CONNECT LAV0 /NOADA/DRIVER=LAVDRIVER
X;
X;        Note: LAVDRIVER.EXE should reside in `091SYS$LDR`093
X;
X;
X; SPECIAL REQUIREMENTS:
X;
X;    none
X;
X; LANGUAGE:
X;
X;    VAX-11 MACRO
X;
X; PARAMETERS:
X;
X;    none
X;
X; SPECIAL TECHNIQUES:
X;
X;    none
X;
X; AUTHOR:
X;
X;    David Kashtan
X;
X; DATE CREATED:
X;
X;    Wed Jul 21 11:25:19 1982
X;
X; MAINTAINED BY:
X;
X;    David Kashtan
X;
X; UPDATES:
X;
X;    Modified for VMS V5 SMP  Thu Oct 8 1987       Kenneth Adelman / LBL
X;
X;---------------S-R-I-International-Artificial-Intelligence-Center----------
V-
X`032
X    .SBTTL    DEFINITIONS
X    .LIBRARY    /SYS$LIBRARY:LIB.MLB/
X;+ ---
X;
X; DEFINE CONTROL BLOCK OFFSETS & OTHER SYSTEM STUFF BY CALLING 'DEF' MACROS
X;
X;- ---
XIF    DF,VMS_V5
X    $CPUDEF            ;DEFINE PER-CPU STRUCTURE
XENDC
X    $CRBDEF            ;DEFINE CHANNEL REQUEST BLOCK
X    $DCDEF            ;DEFINE DEVICE TYPES
X    $DDBDEF            ;DEFINE DEVICE DATA BLOCK
X    $DEVDEF            ;DEFINE DEVICE CONSTANTS
X    $DPTDEF            ;DEFINE DRIVER PROLOGUE TABLE
X    $DYNDEF            ;DEFINE DYNAMIC STRUCTURE CODES
X    $FKBDEF            ;DEFINE FORK BLOCK CODES
X    $IODEF            ;DEFINE I/O FUNCTION CODES
XIF    NDF,VMS_V5
X    $IPLDEF            ;DEFINE INTERRUPT PRIORITY LEVELS
XENDC
X    $IRPDEF            ;DEFINE I/O REQUEST PACKET
X    $PCBDEF            ;DEFINE PROCESS CONTROL BLOCK
X    $PHDDEF            ;DEFINE PROCESS HEADER
X    $PRVDEF            ;DEFINE VMS PRIVS
X    $TQEDEF            ;DEFINE TIMER QUEUE ENTRY
X    $UCBDEF            ;DEFINE UNIT CONTROL BLOCK
X    $VECDEF            ;DEFINE VECTOR OFFSETS
X;
X`032
X    .SBTTL    DRIVER PROLOGUE TABLE
X;+ ---
X;
X; DRIVER CHARACTERISTICS
X;
X;- ---
XIF    NDF,VMS_V5
X    DPTAB           -
X            END=LAV_END,           -;END OF DRIVER (SIZE)
X            ADAPTER=NULL,           -;UNIBUS DEVICE
X            UCBSIZE=UCB$C_Length,  -;UNIT CONTROL BLOCK LENGTH
X            MAXUNITS=1,           -;ONLY ONE LAV0 DEVICE
X            UNLOAD=LAV_UNLOAD,     -;UNLOAD ROUTINE
X            NAME=LAVDRIVER        ;DRIVER NAME
XIFF
X    DPTAB           -
X            END=LAV_END,           -;END OF DRIVER (SIZE)
X            ADAPTER=NULL,           -;UNIBUS DEVICE
X            UCBSIZE=UCB$C_Length,  -;UNIT CONTROL BLOCK LENGTH
X            MAXUNITS=1,           -;ONLY ONE LAV0 DEVICE
X            UNLOAD=LAV_UNLOAD,     -;UNLOAD ROUTINE
X            NAME=LAVDRIVER,        -;DRIVER NAME
X            SMP=YES            ;Works under SMP
XENDC
X;+ ---
X;
X; INITIALIZATION INFORMATION
X;
X;- ---
X    DPT_STORE    INIT
XIF    NDF,VMS_V5
X    DPT_STORE    UCB,UCB$B_FIPL,B,8    ;FORK IPL LEVEL
XIFF
X    DPT_STORE    UCB,UCB$B_FLCK,B,SPL$C_IOLOCK8 ;FORK SPINLOCK
XENDC
X    DPT_STORE    UCB,UCB$B_DIPL,B,21    ;DEVICE IPL LEVEL (BR5 = 21)
X    DPT_STORE    UCB,UCB$L_DEVCHAR,L,   -;DEVICE CHARACTERISTICS:
X               <-
X            DEV$M_AVL!           -;   DEVICE AVAILABLE
X            DEV$M_REC!           -;   RECORD ORIENTED
X            DEV$M_IDV!           -;   INPUT DEVICE
X            DEV$M_SHR           -;   SHARED
X               >
X    DPT_STORE    UCB,UCB$W_DEVBUFSIZ,   -;DEVICE BUFFER SIZE
X                W,36        ;    (36 bytes)
X;+ ---
X;
X; RE-INITIALIZATION INFORMATION
X;
X;- ---
X    DPT_STORE    REINIT
X    DPT_STORE    DDB,DDB$L_DDT,D,LAV$DDT ;DRIVER DISPATCH TABLE
X    DPT_STORE    CRB,               -;CONTROLLER INITIALIZATION ROUTINE
X             CRB$L_INTD+VEC$L_INITIAL,D,-
X                LAV_CONTROLLER_INIT
X    DPT_STORE    CRB,               -;UNIT INITIALIZATION ROUTINE
X             CRB$L_INTD+VEC$L_UNITINIT,D,-
X                LAV_UNIT_INIT
X    DPT_STORE    END
X;
X`032
X    .SBTTL    DRIVER DISPATCH TABLE
X;+ ---
X;
X; ADDRESSES OF VARIOUS DRIVER ENTRY POINTS
X;
X;- ---
X    DDTAB    -
X         DEVNAM=LAV,           -;DEVICE NAME
X         START=0,           -;ADDRESS OF START I/O ENTRY POINT
X         UNSOLIC=0,           -;ADDRESS OF UNSOLICITED INT. ROUTINE
X         FUNCTB=LAV_FUNCTABLE, -;ADDRESS OF FUNCTION DECISION TABLE
X         CANCEL=0,           -;ADDRESS OF CANCEL I/O ENTRY POINT
X         REGDMP=0,           -;ADDRESS OF REGISTER DUMP ROUTINE
X         DIAGBF=0,           -;SIZE OF DIAGNOSTIC BUFFER
X         ERLGBF=0        ;SIZE OF ERROR LOG BUFFER
X;
+-+-+-+-+-+-+-+-  END  OF PART 7 +-+-+-+-+-+-+-+-

