From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  1-DEC-1989 15:26
To:	MRGATE::"ARISIA::EVERHART"
Subj:	MONMODE Christmas is coming 2/2

Message-Id:  <8912012018.AA12502@crdgw1.ge.com>
Received: From NSFNET-RELAY.AC.UK by CRVAX.SRI.COM with TCP; Fri,  1 DEC 89 10:24:42 PDT
Received: from sun.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK 
           via Janet with NIFTP  id aa13561; 1 Dec 89 17:51 GMT
Date:           Fri, 1 Dec 89  17:57 BST
From: Nick de Smith <"PSI%JANET.000000000040::NICK%ncdlab.ulcc.ac.uk"@NSFnet-Relay.AC.UK>
To: INFO-VAX <@NSFnet-Relay.AC.UK:INFO-VAX@crvax.sri.com>
Subject:        MONMODE Christmas is coming 2/2

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X$! Determine the state of the processor, and collect all the counters.
X$! Note we have to subtract the idle ticks from the interrupt ticks, as unde
Vr V5 idle time is
X$! spent on the interrupt stack. If we don't do this, idle time appears twic
Ve.
X$!
X$ GET_CPU_DATA:
X$`009CPU`009`009= 0`009`009`009`009`009`009`009! CPU number to check
X$`009Mask`009`009= 1`009`009`009`009`009`009`009! 2`094CPU
X$`009CPU_Count`009= 0`009`009`009`009`009`009`009! Count of active CPUs
X$`009Max_CPU_Number`009= -1`009`009`009`009`009`009`009! Highest CPU nnumber
V in use
X$`009Active_CPUs`009= 'LPeek SMP$GL_ACTIVE_CPUS 'Ep`009`009`009`009! Mask of
V active SMP CPUs
X$`009If .not. First_Time Then Last_System_TICs = System_TICs`009`009`009! If
V not first time, save previous system ticks
X$`009System_TICs`009= 'LPeek EXE$GL_ABSTIM_TICS 'Ep`009`009`009`009! TICs si
Vnce system boot
X$ 100$:`009If (Mask .and. Active_CPUs) .ne. 0
X$`009Then`009CPU_Count = CPU_Count + 1`009`009`009`009`009! Count number of
V CPU's found
X$`009`009Max_CPU_Number`009= CPU`009`009`009`009`009`009! Highest CPU number
V in use
X$`009`009CPU_Data`009= 'LPeek SMP$GL_CPU_DATA + 4 * CPU 'Ep`009`009! => per
V CPU data area
X$`009`009If .not. First_Time Then Last_Mode_Time_'CPU = Mode_Time_'CPU`009!
V If not first time, save the previous times
X$`009`009Mode_Time_'CPU`009= F$Fao( "!AD", CPU$S_KERNEL + 4, CPU_Data + CPU$
VL_KERNEL ) ! Get CPU's mode times
X$`009`009Mode_Time_'CPU`091 CPU_L_INTERRUPT * 8, 32 `093 = -`009`009`009! St
Vop idle time being counted twice
X`009`009`009F$CvUI( CPU_L_INTERRUPT * 8, 32, Mode_Time_'CPU ) - F$CvUI( CPU_
VL_IDLE * 8, 32, Mode_Time_'CPU )
X$`009`009State_'CPU`009= F$Element( 'BPeek CPU_Data + CPU$B_STATE 'Ep, ",",
V CPU_State ) ! Get CPU state
X$`009`009If State_'CPU .eqs. "," Then State_'CPU  = "* Unknown *"`009! Shoul
Vd never happen
X$`009Else
X$`009`009Mode_Time_'CPU`009`009= Zero_Data `009`009`009`009! ...else no data
V for this CPU
X$`009`009Last_Mode_Time_'CPU`009= Zero_Data
X$`009`009State_'CPU`009`009= "* Unknown *"
X$`009EndIf
X$`009CPU`009= CPU + 1
X$`009If CPU .lt. Max_CPU`009`009`009`009`009`009`009! If more CPUs to scan..
V.
X$`009Then`009Mask`009= Mask * 2`009`009`009`009`009`009! ...move the mask up
V one bit
X$`009`009Goto 100$`009`009`009`009`009`009`009! ...and look for another CPU
X$`009EndIf
X$`009First_Time = FALSE`009`009`009`009`009`009`009! Not first time through
V any more
X$`009Return %x1
X$!
X$ END:`009If Saved_Width .ne. Width`009`009`009`009`009`009! If terminal wid
Vth needs restoring...
X$`009Then`009Set Terminal /Width=&Saved_Width`009`009`009`009! ...restore te
Vrminal width
X$`009Else`009Say F$Fao( At, F$GetDVI( "SYS$COMMAND", "TT_PAGE" ), 1 )`009! .
V..else move to end of screen
X$`009EndIf
X$ END_1:Setv = F$Verify( Setv )
$ CALL UNPACK MONMODE.COM;2 2755164043
$ v=f$verify(v)
$ EXIT

