[comp.os.vms] Nanny Source V1.0 1/14

zar@Hamlet.Caltech.EDU (Dan Zirin) (06/30/87)

$!------------------------------Cut Here-------------------------
$ chk = "1043101439"
$ create nt1.tex
$ deck/dollars="ThEgReAtZaR"
\font\chapfont=cmbx10 scaled\magstep3
\font\subrubfont=cmbx10 scaled\magstephalf

\parskip=\bigskipamount
\parindent=0mm
\hsize=14truecm
\hoffset=1truecm
\vsize=23truecm
\voffset=.5truecm
\topskip=1truecm

\footline={\hfil}
\headline={\it\firstmark\hfil\folio}
\def\makeheadline{\vbox to 0pt{\vskip-.7truecm
    \ifnum\pageno=1 \else
        \ifnum\pageno<0 \line{\it\hfil\folio}\smallskip \hrule
        \else \line{\the\headline}\smallskip\hrule\fi\fi
        \vss}\nointerlineskip}

\newcount\chapcount \newcount\subcount \newcount\subsubcount
\chapcount=0 \subcount=0 \subsubcount=0

\def\chapter#1\par{\vskip 0pt plus.4\vsize \goodbreak
    \vskip 0pt plus-.4\vsize \bigskip \bigskip
    \advance \chapcount by 1 \subcount=0 \subsubcount=0
    \chapcontents{#1}\mark{\the\chapcount.\enspace#1}%
    {\chapfont \setbox0=\hbox{\the\chapcount.\enspace}\hangindent=\wd0
        \baselineskip=20truept \raggedright
        \noindent \box0 #1\bigskip \nobreak}}

\def\subrub#1\par{\vskip 0pt plus.3\vsize \goodbreak
    \vskip 0pt plus-.3\vsize \bigskip
    \advance \subcount by 1 \subsubcount=0
    \subcontents{#1}%
    {\subrubfont \setbox0=\hbox{\the\chapcount.\the\subcount\enspace}%
        \baselineskip=17truept \hangindent=\wd0
        \raggedright \noindent \box0 #1\medskip \nobreak}}

\def\subsubrub#1\par{\vskip 0pt plus.3\vsize \goodbreak
    \vskip 0pt plus-.3\vsize \bigskip
    \advance \subsubcount by 1
    \subsubcontents{#1}%
    {\bf\setbox0=\hbox{\the\chapcount.\the\subcount.\the\subsubcount\enspace}%
        \baselineskip=14truept \hangindent=\wd0
        \raggedright \noindent \box0 #1\medskip \nobreak}}

\newwrite\contents
\immediate\openout\contents=\jobname.contents

\def\chapcontents#1{\immediate\write\contents{\noexpand\chapline%
    {\the\pageno}{\the\chapcount}{#1}}}
\def\subcontents#1{\immediate\write\contents{\noexpand\subline%
    {\the\pageno}{\the\chapcount.\the\subcount}{#1}}}
\def\subsubcontents#1{\immediate\write\contents{\noexpand\subsubline%
    {\the\pageno}{\the\chapcount.\the\subcount.\the\subsubcount}{#1}}}

\long\def\bye{\immediate\closeout\contents\vfil\supereject\docontents\end}

\def\docontents{\pageno=-1\bf\parskip=0pt\parindent=0pt
    \def\punkter{\leaders\hbox to .75em{\hss.\hss}\hfill}
    \def\chapline##1##2##3{\smallskip\noindent##2\enspace##3\punkter##1}
    \def\subline##1##2##3{\smallskip\noindent\qquad##2\enspace##3\punkter##1}
    \def\subsubline##1##2##3{\smallskip\noindent
        \qquad\qquad##2\enspace##3\punkter##1}
    \vglue1cm
    \input \jobname.contents
    \vfil\supereject}

\newskip\ttglue{\tt \global\ttglue=.5em plus.25em minus.15em}
\chardef\other=12
\def\ttverbatim{\begingroup \catcode`\\=\other \catcode`\{=\other
    \catcode`\}=\other \catcode`\$=\other \catcode`\&=\other
    \catcode`\#=\other \catcode`\%=\other \catcode`\~=\other
    \catcode`\_=\other \catcode`\^=\other
    \obeyspaces \obeylines \tt}
{\obeyspaces\gdef {\ }}
\def\;{\char'73 }
\catcode`\;=\active
{\obeylines\gdef;{\ttverbatim\spaceskip=\ttglue\let^^M=\ \let;=\endgroup}}
\font\BIG=cmbx10 scaled\magstep5

\null\vfil
\centerline{\BIG N A N N Y}\bigskip\bigskip
\centerline{A Creation Of}
\centerline{Zar ltd.}
\vfil

The contents of this document and all matter described herein are
licensed solely by Zar ltd.\ and must not be duplicated or transferred
without written consent of Zar ltd. Questions and comments can be
directed to:

\bigskip\bigskip
\centerline{Daniel Zirin}
\centerline{Zar ltd.}
\centerline{P.O. Box 372}
\centerline{Pasadena, Cal 91102}
\bigskip\bigskip\eject

\pageno=1

\chapter Introduction

Nanny is a program to maintain an even balance of CPU for all
non-system processes, to allow individual users special commands to
manipulate processes with the same UIC, and to do various other
functions available to system users or standard users.

Nanny runs as a detached system process and reads all commands from a
system-wide permanent mailbox assigned to the logical name
NANNYS\$BOX. Included with this package are several programs which use
Nanny's commands. When you distribute these programs to your VAX
community, it is a good idea to protect the source and only allow
access to the executable. If you feel too threatened by allowing use
of one or many Nanny commands, a bit mask exists to disable one or all
of Nanny's commands.

Each time Nanny is started, she reads predefined values from a
parameter file to determine your system's site-specific requirements
and system dependent values that allow each system a means of
modifying Nanny in accord with the needs of your computer. For more
flexibility, a special command permits you to reread these values.

Each and every action Nanny takes, including any errors that may
occur, are written into a log file. This log file is closed nightly at
12:00, a new log file is opened, and the parameter file, described in
the previous paragraph, is reread. Many errors and/or status messages
from the Nanny will also appear on designated Nanny operator
terminals.

The next few sections will describe each command and function of
Nanny.

\chapter Priorities

Nanny is in an endless loop, checking for new processes, updating the
states of old processes, checking for processes removed from the
system, and performing other functions. Each loop is a cycle and at
the end of each cycle, Nanny will wait a specified time (usually
between 15 and 60 seconds) before starting another cycle. All
priorities are reestablished for each cycle of Nanny, regardless of
the demand on the system. The following algorithm determines what
priority the job will have after each cycle:
$$
\eqalign{newpri = &oldpri + 1 \hbox{\quad if}\cr
                  &cpuused < (cycletime * 1.1) / numusers\cr}
$$
or
$$
\eqalign{newpri = &oldpri - 1 \hbox{\quad if}\cr
                  &cpuused > ( cycletime / numusers ) * 1.1\cr}
$$
$Numusers$ are all processes with the same login priority AND the same
job mode (such as batch or interactive mode) AND does not increase
because of duplicate users. For example, if the users DXL, SHR, and
DMR were all batch jobs with a login priority of 3, $numusers$ for DXL
would be the value 3. But if DXL added another job to the same batch
queue (with the same login priority), $numusers$ would still be 3 only
allowing DXL one third of the CPU no matter how many jobs he added to
the same queue (this is optional and can be determined by bit flags in
the parameter file for each process type). $Cpuused$ is your
accumulated CPU usage since the last cycle. Priorities are not lowered
less than the process' login priority less one and are not raised
above the process' login priority. The $cycletime$ is determined from
the parameter file, described in detail later. It is also possible to
ask Nanny to use a running average in determining CPU use by changing
a parameter file variable.

\chapter Idle processes

All non-system interactive processes are checked during each cycle to
determine if the user has been idle. If the process has been idle for
more than the maximum allowable time (another parameter file
constant), the process is deleted. This action, though, is not taken
without warnings. A warning is sent to the process at $maxtime$
divided by 2 and again 30 seconds before logout. When the process is
logged out, an appropriate message is displayed at the process's
terminal. Idle time and $maxtime$ are constants in the parameter file.

It is possible to have a process not appear idle to Nanny when in fact,
it is (such as KERMIT is server mode). To handle this, Nanny has another
optional $maxelapsed$ parameter file variable that will force a user to
exit an image after the time specified by $maxelapsed$ (usually something
like 18-20 hours).

\chapter Commands

All commands sent to Nanny must take the form:

\nobreak{\tt\qquad command mbxch [arg1 [arg2 [\dots] ] ]}

The command must not be abbreviated and the entire message must be
followed by a space (ascii character 32). Each command sent must have
a mailbox device name following the command. Any arguments required by
the command (brackets indicate use if required) must be present and
each argument delimited by at least one space. The maximum length of a
command sent to Nanny can be 128 bytes long. When a command requires a
process I.D., the value must be represented in hexidecimal form. If
Nanny receives an unknown command or a command not properly assembled,
it will be ignored. If a command is unneeded or unwanted, you may
disable its use. A parameter file constant allows one command or all
commands to be disabled from system use. This constant is described
later.

After the message is sent to Nanny, the user may optionally read a
status byte from the mailbox specified with the command. The byte will
either be 1 for successful completion, or 32 to signify an error
occurred while attempting to complete the command.

\subrub ADDACC

The command ADDACC will add a user record to your system's accounting
data file via the system service \$SNDACC. ADDACC requires two
arguments: the process I.D.\ of the requester and the character string
to insert into the accounting data file.

\subrub DIE

The command DIE will request Nanny to return all processes to their
original priorities and terminate execution. This command requires no
arguments. If the requestor's group UIC number is greater than the
defined system group UIC number (explained later), the command will
not be performed.

\subrub ENTER

The command ENTER will ask the Nanny to start monitoring a process
removed with the FORGET command. This command requires two arguments:
The target process I.D. and the requestor's process I.D.. If the
requesting process group UIC number is greater than the defined system
group UIC number, no action will be taken.

\subrub FORGET

The command FORGET will ask to remove a process from Nanny's
observation. This command requires two arguments: the target process
I.D.\ and the requestor's process I.D.. If the requesting process
group UIC number is greater than the defined system group UIC number,
no action will be taken.

\subrub FREE

The FREE command will tell Nanny to deallocate a device allocated with
the GRAB command. This command requires one argument: the name of the
device to be deallocated. If the requesting process group UIC number
is greater than the defined system group UIC number, no action will be
taken.

\subrub GRAB

The GRAB command allocates a device to disallow system access to the
device. This command requires one argument: the name of the device to
be allocated. If the requesting process group UIC number is greater
than the defined system group UIC number, no action will be taken.

\subrub IGNORE

The IGNORE (opposite of LISTEN) command is not available at this time.

\subrub KILL

The command KILL will request Nanny to delete a process. The process
must have the same UIC as the request process or no action will be
taken. This command requires two arguments: the target process I.D.\
and the requestor's process I.D..

\subrub LISTEN

The LISTEN (opposite of IGNORE) command is not available at this time.

\subrub NEW

The command NEW will close the current log file, open a new one, and
reread the parameter file. This command has no arguments and can be
issued by all processes. If the requesting process group UIC number is
greater than the defined system group UIC number, no action will be
taken.

\subrub ODIS

The command ODIS will disable a previously enabled operator terminal
from receiving all operator messages. This comand has one argument:
the requestor's process I.D..

\subrub OEN

The command OEN will enable a terminal as an operator terminal to
receive all operator messages. This command has one argument: the
requestor's process I.D..

\subrub QSTART

The command QSTART will start or restart a specified queue. The
command requires two arguments: the name of the queue to start and the
process I.D.\ of the requestor.

\subrub QSTOP

The command QSTOP will stop or pause a specified batch or print queue.
This command requires two arguments: the name of the queue to stop and
the requestor's process I.D..

\subrub REQUEUE

The command REQUEUE will take the current job in a paused or stopped
print queue and requeue the job at the end of the print queue. This
command requires two arguments: the name of the print queue and the
requestor's process I.D..

\subrub RESUME

The command RESUME will remove a process from a suspended state via
the system service \$RESUME. This command requires two arguments: the
target process I.D.\ and the requestor's process I.D.. If the target
process and the requesting process do not have the same UIC, no action
will be taken.

\subrub STOP

The command STOP will cause a process executing an image to terminate
the image with the system service \$FORCEX. The requesting process and
target process must have the same UICs. This command requires two
arguments: the target process I.D.\ and the requestor's process I.D..

\subrub SUSPEND

The command SUSPEND will cause a process to enter a suspended state.
This command has two arguments: the target process I.D.\ and the
requestor's process I.D.. Both processes must have the same UIC or no
action will be taken.

ThEgReAtZaR
$ checksum nt1.tex
$ if chk.nes.checksum$checksum then write sys$output -
  "NT1.TEX didn't pass checksum. File may be corrupted."
$ if chk.nes.checksum$checksum then exit %x2c
$ exit