From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 25-JUL-1989 07:16
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Program Nulltime, VMS 5.x, Part 1 of 2

Message-Id:  <8907251101.AA18048@crdgw1.ge.com>
Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue, 25 JUL 89 03:04:23 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Tue, 25 Jul 89 02:37:10 PDT
Received: from DBTHRZ5.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 6487; Tue, 25 Jul 89 05:38:16 EDT
Date: 25 JUL 89 11:14-MEZ
From: BTR011%DBTHRZ5.BITNET@CUNYVM.CUNY.EDU
To: INFO-VAX@KL.SRI.COM
Subject: Program Nulltime, VMS 5.x, Part 1 of 2

Date: 25-JUL-1989 11:14:21.63
From: Tom Rueger, HRZ Uni Bayreuth BTR011 AT DBTHRZ5
To:   BITNET::"INFO-VAX@KL.SRI.COM"
Subj: Program Nulltime, VMS 5.x, Part 1 of 2
att!occrsh!uokmax!brmorrow@ucbvax.Berkeley.EDU writes:

>We are running a VAX 11/780 under VMS 5.1-1 and we would
>like to know how to get the amount of Null time.

>What we need is some kind of a routine that can go out and
>get it and return a value as to what it finds.

and Peter Scott <PJS@GROUCH.JPL.NASA.GOV>:

>Ditto!!!  We too would be interested in *any* method that doesn't
>require human interaction that yields the null time for a given
>7-day period.

Now, here is a posting of a little FORTRAN-Program called NULLTIME,
that calculates the idletime of a VAX/VMS 5.x. I could only test it
on monoprocessors (VAX 8600, VAX 6310 and several VAXStations), but
it should run as well on multiprocessors.

 Tom Rueger
 System Manager
 HRZ Uni Bayreuth
 EARN/BITNET: BTR011@DBTHRZ5
 X.400:<S=rueger;OU=ubt0;OU=hrz;P=uni-bayreuth;A=dbp;C=de>

..................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.01 12-Oct-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user BTR011
$! on 25-JUL-1989 11:10:27.90.
$!
$! ATTENTION: To keep each article below 31 blocks (15872 bytes), this
$!            program has been transmitted in 2 parts.  You should
$!            concatenate ALL parts to ONE file and execute (@)that file.
$!
$! It contains the following 1 file:
$!        NULL.FOR
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.01 12-Oct-1988 requires VMS V4.4 or higher."
$ EXIT 44
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "$Part", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "$Errors" ); i_errors := 0
; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE
) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 ); IF s_x = "+" THEN r_skip
:= SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <> 0 THEN s_x := ""
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF
; IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = "V" THEN s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL
( 1 ); ENDIF; IF s_x = "X" THEN s_x := ""; IF i_append_line <
> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line
:= 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> "" THEN i_errors := i_errors + 1
; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE; COPY_TEXT
( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL( 1 ); ENDIF
; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH( "`", FORWARD
, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER( 1 )
; IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) )
; COPY_TEXT( FAO( "The following !UL errors were detectedwhile unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors
, "SYS$COMMAND" ); ENDIF; EXIT;
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "NULL.FOR"
$ CHECKSUM_IS = 846204047
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X`009Program Nulltime
XC
XC`009VAX/VMS V5.x, 10-APR-1989,
XC`009program to calculate the idle-time.
XC`009Suitable to mono- and multiprocessors (configured for max. 16 CPUs)
XC`009Privileges required: none
XC
XC`009(c) Tom Rueger
XC`009HRZ Universitaet Bayreuth
XC`009EARN/BITNET:`009BTR011@DBTHRZ5 or SYSTEM@DBTHRZ5
XC`009X.400:`009`009<S=rueger;OU=ubt0;OU=hrz;P=uni-bayreuth;a=dbp;c=de>
XC`009PSI:`009`009PSI%45921052101::BTR011
XC
XC Link:`032
XC   $ LINK NULLTIME,SYS$SYSTEM:SYS.STB/NOTRACE
XC`009
XC
X`009Implicit Integer ( A - Z )`032
X`009Character*80 Ctrlstr`009! Controlstring for $FAO
X`009Character*100 Outstr`009! Outputstring  for $FAO
X`009Character*16 Asctime`009! Time in ASCII-Format
X`009Integer`009Atimelen,`009! Length of Asctime
X`0091`009Inull,`009`009! Idletime in 10 ms-ticks
X`0092`009Active_cpus,`009! Count of active CPUs
X`0093`009Nulltim(2),`009! Idletime in 100 ns-ticks
X`0094`009Absadr,`009`009! Address of absolute uptime
X`0095`009Abstim,         ! Uptime in 1 s-ticks
X`0096`009Uptime(2),`009! Uptime in 100 ns-ticks
X`0097`009Istat`009`009! Return-status of system-services
XC
X`009Integer*2 Outlen        ! Length of output-string
XC
X`009Real`009 Percent`009! Idle-time in percent
XC
X`009Integer`009 Value`009`009! Function to access the value of a variable
X`009`009`009`009! by its address
XC
XC`009Symbols defined in SYS$SYSTEM:SYS.STB
XC
X`009External Exe$Gl_Abstim`009! Address of time since last boot`032
X`009External Smp$Gl_Cpu_Data,! Address of offset of CPU-data-array
X`009`009`009`009 ! for each processor
X`0091`009 Smp$Gl_Cpuconf ! Bitmask showing the active processors
XC
XC`009Begin of executable code
XC
X`009Ctrlstr = 'Utilization at !%D'
X`009Istat = Sys$Fao( Ctrlstr,
X`0091`009`009 ,
X`0092`009`009 Outstr,
X`0093`009`009 %Val(0))
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Istat = Str$Trim(Outstr,Outstr,Outlen)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Write(*,1000) Outstr(:Outlen)
XC
X`009Absadr    = %Loc(Exe$Gl_Abstim)
XC
X`009Abstim    = Value(%Val(Absadr))
XC
X`009Istat = Lib$Emul(Abstim,-10 000 000,0,Uptime)
XC
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Istat = Sys$Asctim(Atimelen,Asctime,Uptime,)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Ctrlstr = 'Time since last boot: !16AS'
XC
X`009Istat = Sys$Fao( Ctrlstr,
X`0091`009`009 Outlen,
X`0092`009`009 Outstr,
X`0093`009`009 Asctime)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Istat = Str$Trim(Outstr,Outstr,Outlen)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Write(*,1000) Outstr(:Outlen)
XC
XC`009Get Idletime of all active processors
XC
X`009Call Get_infos( Inull, Active_cpus )
XC
XC`009Convert from 10 ms-ticks to 64-bit time
XC
X`009Istat = Lib$Emul((Inull/Active_cpus),-100 000,0,Nulltim)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Istat = Sys$Asctim(Atimelen,Asctime,Nulltim,)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Ctrlstr = 'Unused processortime: !16AS'
XC
X`009Istat = Sys$Fao( Ctrlstr,
X`0091`009`009 Outlen,
X`0092`009`009 Outstr,
X`0093`009`009 Asctime)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Istat = Str$Trim(Outstr,Outstr,Outlen)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Write(*,1000) Outstr(:Outlen)
XC
XC`009Calculate percentual idle
XC
X`009Percent = (Float(Inull)/Float(Active_Cpus)/Float(Abstim))
XC
XC`009Output the percentual idletime
XC
X`009Ctrlstr = 'Idle (!UL active processor!%S) : !_ !UL.!2UL% '
XC
X`009Istat = Sys$Fao(Ctrlstr,
X`0091`009`009Outlen,
X`0092`009`009Outstr,
X`0093`009`009%Val(Active_Cpus),
X`0094`009`009%Val(Int(Percent)),
X`0095`009`009%Val(Int(100.*(Percent-Float(Int(Percent))))))
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Istat = Str$Trim(Outstr,Outstr,Outlen)
X`009If (.Not. Istat) Call Lib$Stop(%Val(Istat))
XC
X`009Write (*,1000) Outstr(:Outlen)`032
XC
XC`009Formats
XC
X1000`009Format (X,A)`032
XC
XC `009All done
XC
X`009End
XC--------------------------------------------------------------------
XC Routine to access a variable by its address ( MOVL @#Address,Value )
X`009Integer Function Value(Address)
X`009Integer Address
X`009Value = Address
X`009Return`032
X`009End
XC==============================================================================
X`009Subroutine Get_Infos( INull , Active_Cpus )
XC
X`009Implicit Integer( A - Z )
XC
X`009Integer*4`009Inull`009`009  ! Count of ticks in idle mode
X`0091`009`009Anull`009`009  ! Address of Nullmode
XC
X!`009Include`009'($Cpudef)'
X`009PARAMETER ( CPU$B_BUSYWAIT                  = '0000000C'X )
X`009PARAMETER ( CPU$B_CPUDATA                   = '0000004C'X )
X`009PARAMETER ( CPU$B_CPUMTX                    = '0000000E'X )
X`009PARAMETER ( CPU$B_CUR_PRI                   = '0000000F'X )
X`009PARAMETER ( CPU$B_QLOST_FLCK                = '0000024B'X )
X`009PARAMETER ( CPU$B_QLOST_TYPE                = '0000024A'X )
X`009PARAMETER ( CPU$B_STATE                     = '0000000D'X )
X`009PARAMETER ( CPU$B_SUBTYPE                   = '0000000B'X )
X`009PARAMETER ( CPU$B_TYPE                      = '0000000A'X )
X`009PARAMETER ( CPU$C_8NN_CPUS                  = '00000002'X )
X`009PARAMETER ( CPU$C_8PS_CPUS                  = '00000004'X )
X`009PARAMETER ( CPU$C_8SS_CPUS                  = '00000010'X )
X`009PARAMETER ( CPU$C_9CC_CPUS                  = '00000010'X )
X`009PARAMETER ( CPU$C_9RR_CPUS                  = '00000010'X )
X`009PARAMETER ( CPU$C_BOOTED                    = '00000007'X )
X`009PARAMETER ( CPU$C_BOOT_REJECTED             = '00000006'X )
X`009PARAMETER ( CPU$C_INIT                      = '00000001'X )
X`009PARAMETER ( CPU$C_LENGTH                    = '0000033C'X )
X`009PARAMETER ( CPU$C_MAX_CPUS                  = '00000020'X )
X`009PARAMETER ( CPU$C_PAGE0_LENGTH              = '00000078'X )
X`009PARAMETER ( CPU$C_PAGECNT                   = '00000002'X )
X`009PARAMETER ( CPU$C_RESERVED                  = '00000000'X )
X`009PARAMETER ( CPU$C_RUN                       = '00000002'X )
X`009PARAMETER ( CPU$C_STACK                     = '00000800'X )
X`009PARAMETER ( CPU$C_STOPPED                   = '00000004'X )
X`009PARAMETER ( CPU$C_STOPPING                  = '00000003'X )
X`009PARAMETER ( CPU$C_TIMOUT                    = '00000005'X )
X`009PARAMETER ( CPU$K_LENGTH                    = '0000033C'X )
X`009PARAMETER ( CPU$K_NUM_SWIQS                 = '00000006'X )
X`009PARAMETER ( CPU$K_PAGE0_LENGTH              = '00000078'X )
X`009PARAMETER ( CPU$L_8NN_INFO                  = '00000058'X )
X`009PARAMETER ( CPU$L_8NN_REVR2                 = '00000050'X )
X`009PARAMETER ( CPU$L_8NN_SID                   = '0000004C'X )
X`009PARAMETER ( CPU$L_8NN_SPARE                 = '00000054'X )
X`009PARAMETER ( CPU$L_8NN_SPARE1                = '0000005C'X )
X`009PARAMETER ( CPU$L_8NN_SPARE2                = '00000060'X )
X`009PARAMETER ( CPU$L_8NN_SPARE3                = '00000064'X )
X`009PARAMETER ( CPU$L_8NN_SPARE4                = '00000068'X )
X`009PARAMETER ( CPU$L_8SS_BIWINDOW              = '00000054'X )
X`009PARAMETER ( CPU$L_8SS_MPB                   = '00000058'X )
X`009PARAMETER ( CPU$L_8SS_SID                   = '0000004C'X )
X`009PARAMETER ( CPU$L_8SS_SPARE1                = '0000005C'X )
X`009PARAMETER ( CPU$L_8SS_SPARE2                = '00000060'X )
X`009PARAMETER ( CPU$L_8SS_SPARE3                = '00000064'X )
X`009PARAMETER ( CPU$L_8SS_SPARE4                = '00000068'X )
X`009PARAMETER ( CPU$L_9CC_MPB                   = '00000054'X )
X`009PARAMETER ( CPU$L_9CC_NODESPACE             = '00000050'X )
X`009PARAMETER ( CPU$L_9CC_SID                   = '0000004C'X )
X`009PARAMETER ( CPU$L_9CC_SPARE1                = '0000005C'X )
X`009PARAMETER ( CPU$L_9CC_SPARE2                = '00000060'X )
X`009PARAMETER ( CPU$L_9CC_SPARE3                = '00000064'X )
X`009PARAMETER ( CPU$L_9CC_SPARE4                = '00000068'X )
X`009PARAMETER ( CPU$L_9CC_XSID                  = '00000058'X )
X`009PARAMETER ( CPU$L_9RR_MPB                   = '00000054'X )
X`009PARAMETER ( CPU$L_9RR_NODESPACE             = '00000050'X )
X`009PARAMETER ( CPU$L_9RR_SID                   = '0000004C'X )
X`009PARAMETER ( CPU$L_9RR_SPARE1                = '0000005C'X )
X`009PARAMETER ( CPU$L_9RR_SPARE2                = '00000060'X )
X`009PARAMETER ( CPU$L_9RR_SPARE3                = '00000064'X )
X`009PARAMETER ( CPU$L_9RR_SPARE4                = '00000068'X )
X`009PARAMETER ( CPU$L_9RR_XSID                  = '00000058'X )
X`009PARAMETER ( CPU$L_BUGCODE                   = '00000048'X )
X`009PARAMETER ( CPU$L_CAPABILITY                = '0000026C'X )
X`009PARAMETER ( CPU$L_CPUID_MASK                = '00000260'X )
X`009PARAMETER ( CPU$L_CURPCB                    = '00000000'X )
X`009PARAMETER ( CPU$L_HALTPC                    = '00000020'X )
X`009PARAMETER ( CPU$L_HALTPSL                   = '00000024'X )
X`009PARAMETER ( CPU$L_INTSTK                    = '00000010'X )
X`009PARAMETER ( CPU$L_IPL_ARRAY                 = '000002B4'X )
X`009PARAMETER ( CPU$L_IPL_VEC                   = '000002B0'X )
X`009PARAMETER ( CPU$L_KERNEL                    = '00000278'X )
X`009PARAMETER ( CPU$L_MCHK_MASK                 = '0000006C'X )
X`009PARAMETER ( CPU$L_MCHK_SP                   = '00000070'X )
X`009PARAMETER ( CPU$L_NULLCPU                   = '00000294'X )
X`009PARAMETER ( CPU$L_P0BR                      = '00000038'X )
X`009PARAMETER ( CPU$L_P0LR                      = '0000003C'X )
X`009PARAMETER ( CPU$L_P0PT_PAGE                 = '00000074'X )
X`009PARAMETER ( CPU$L_P1BR                      = '00000040'X )
X`009PARAMETER ( CPU$L_P1LR                      = '00000044'X )
X`009PARAMETER ( CPU$L_PCBB                      = '0000002C'X )
X`009PARAMETER ( CPU$L_PERCPUVA                  = '00000018'X )
X`009PARAMETER ( CPU$L_PHY_CPUID                 = '00000268'X )
X`009PARAMETER ( CPU$L_PSBL                      = '00000234'X )
X`009PARAMETER ( CPU$L_PSFL                      = '00000230'X )
X`009PARAMETER ( CPU$L_QLOST_FPC                 = '0000024C'X )
X`009PARAMETER ( CPU$L_QLOST_FQBL                = '00000244'X )
X`009PARAMETER ( CPU$L_QLOST_FQFL                = '00000240'X )
X`009PARAMETER ( CPU$L_QLOST_FR3                 = '00000250'X )
X`009PARAMETER ( CPU$L_QLOST_FR4                 = '00000254'X )
X`009PARAMETER ( CPU$L_RANK_VEC                  = '000002AC'X )
X`009PARAMETER ( CPU$L_REALSTACK                 = '00000004'X )
X`009PARAMETER ( CPU$L_SAVED_AP                  = '0000001C'X )
X`009PARAMETER ( CPU$L_SAVED_ISP                 = '00000028'X )
X`009PARAMETER ( CPU$L_SCBB                      = '00000030'X )
X`009PARAMETER ( CPU$L_SID                       = '0000004C'X )
X`009PARAMETER ( CPU$L_SISR                      = '00000034'X )
X`009PARAMETER ( CPU$L_TENUSEC                   = '00000270'X )
X`009PARAMETER ( CPU$L_TPOINTER                  = '00000334'X )
X`009PARAMETER ( CPU$L_UBDELAY                   = '00000274'X )
X`009PARAMETER ( CPU$L_WORK_REQ                  = '00000014'X )
X`009PARAMETER ( CPU$M_BUGCHK                    = '00000008'X )
X`009PARAMETER ( CPU$M_BUGCHKACK                 = '00000010'X )
X`009PARAMETER ( CPU$M_CPUFILL_1                 = '0FFFFFFF'X )
X`009PARAMETER ( CPU$M_CPUSPEC1                  = '10000000'X )
X`009PARAMETER ( CPU$M_CPUSPEC2                  = '20000000'X )
X`009PARAMETER ( CPU$M_CPUSPEC3                  = '40000000'X )
-+-+-+-+-+ End of part 1 +-+-+-+-+-

