[comp.os.vms] update for SHOMOD.COM

U0012@DGOGWDG5.BITNET ("GWDGV1::MOELLER") (05/21/88)

When I posted SHOMOD.COM on March 31, I asked
>       How do YOU find the system idle time?
Now I learned it from LTL@CUGSBVAX (poster of CLOCK.FOR on April 20,
which I received - on BITNET - on May 17), so here goes ...

[ usage: $ EDIT/SUM SHOMOD.COM/UPDATE=SHOMOD.DIF ]

...................... Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.01 01-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by MOELLER
$! on Friday 20-MAY-1988 20:00:35.34
$!
$! It contains the following 1 file:
$! SHOMOD.DIF
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="SHOMOD.DIF"
$ Check_Sum_is=41829994
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X-    4,    4
X-    8
X$! mod 20-may-1988 wjm: NULL phd is readable, get "nullticks" from there
X$!`009`009`009(credit: LTL@CUGSBVAX's CLOCK program)
X-   22
X$ sch$gl_nullpcb=%x800024a8
X$ pcb$l_phd=%x6c
X$ phd$l_cputim=%x38
X$!
X-   26,   59
X$!*****`009get performance data
X$!
X$ nullphd=f$cvui(0,32,f$fao("!AD",4,sch$gl_nullpcb+pcb$l_phd))
X$!
X$ nullticks=f$cvui(0,32,f$fao("!AD",4,nullphd+phd$l_cputim))
X/
$ GoSub Convert_File
$ Exit

BTW: make sure your copy of this mail file does not contain TRAILING BLANKS
so the checksum will come out right.
Is there a version of VMS_SHAR which properly deals with TRAILING BLANKS?

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
Bitnet/Earn: U0012@DGOGWDG5         Phone: +49 551 201516 | No claim intended

jeh@crash.cts.com (Jamie Hanrahan) (05/25/88)

The referenced article contains DCL "code" which obtains the system idle time,
which is in fact the CPU-time counter in the null process's PHD.)

Two comments.  First, be aware that the NULL process "executes" in kernel
mode.  Code that is getting NULL's cpu time is probably also getting the
processor-mode clock-tick counters from the six-longword vector at 
PMS$GL_KERNEL.  (The longwords contain the Kernel, Exec, Supv, User, 
Interrupt-stack, and Compatibility-mode time, in that order.)  Since NULL
executes in kernel mode, its time is reflected in the kernel-mode counter.
If you're looking to generate information a la the MONITOR MODES display,
you should subtract NULL's CPU time from the value you get from the kernel-
mode counter; what's left is the true kernel-mode time.  


Second, this changes in V5.  The vestiges of the NULL process still exist,
but it is never scheduled to run.  A new structure, the per-CPU database
(CPU$), includes eight longwords in which the times are kept (K, E, S, U, 
I, C, spinlock busy-wait, and idle time).  There is a vector which contains
the addresses of all of the per-CPU data bases in the system; a proper
performance-data-collector should scan the vector, look at each CPU$ 
structure, and add up the results, after acquiring an appropriate 
spinlock -- HWCLK looks like a good choice.  I don't know the name of
the global longword that points to the vector, but I should be able
to find out.  Within the CPU data base, the fields you want are CPU$L_KERNEL
for the seven-longword array, followed by CPU$L_NULLCPU for the idle time.
(The one follows the other now, but I wouldn't count on that forever.)
I don't know if any of the times "overlap" the way kernel and null used
to.

info-vax-request%kl.sri.COM%KL.SRI.COM%lbl%sfsu1.hepnet@LBL.GOV (05/28/88)

Received: from KL.SRI.COM by LBL.Gov with INTERNET ;
          Fri, 27 May 88 03:56:07 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Wed 25 May 88 14:27:15-PDT
Received: by ucbvax.Berkeley.EDU (5.59/1.28)
	id AA00157; Wed, 25 May 88 04:37:45 PDT
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 25 May 88 00:30:21 GMT
From: hp-sdd!ucsdhub!jack!crash!jeh@hplabs.hp.com  (Jamie Hanrahan)
Organization: Crash TS, El Cajon, CA
Subject: Re: update for SHOMOD.COM
Message-Id: <3016@crash.cts.com>
References: <8805240321.AA00906@ucbvax.Berkeley.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com
 
The referenced article contains DCL "code" which obtains the system idle time,
which is in fact the CPU-time counter in the null process's PHD.)
 
Two comments.  First, be aware that the NULL process "executes" in kernel
mode.  Code that is getting NULL's cpu time is probably also getting the
processor-mode clock-tick counters from the six-longword vector at 
PMS$GL_KERNEL.  (The longwords contain the Kernel, Exec, Supv, User, 
Interrupt-stack, and Compatibility-mode time, in that order.)  Since NULL
executes in kernel mode, its time is reflected in the kernel-mode counter.
If you're looking to generate information a la the MONITOR MODES display,
you should subtract NULL's CPU time from the value you get from the kernel-
mode counter; what's left is the true kernel-mode time.  
 
 
Second, this changes in V5.  The vestiges of the NULL process still exist,
but it is never scheduled to run.  A new structure, the per-CPU database
(CPU$), includes eight longwords in which the times are kept (K, E, S, U, 
I, C, spinlock busy-wait, and idle time).  There is a vector which contains
the addresses of all of the per-CPU data bases in the system; a proper
performance-data-collector should scan the vector, look at each CPU$ 
structure, and add up the results, after acquiring an appropriate 
spinlock -- HWCLK looks like a good choice.  I don't know the name of
the global longword that points to the vector, but I should be able
to find out.  Within the CPU data base, the fields you want are CPU$L_KERNEL
for the seven-longword array, followed by CPU$L_NULLCPU for the idle time.
(The one follows the other now, but I wouldn't count on that forever.)
I don't know if any of the times "overlap" the way kernel and null used
to.