@V7 54 2 -5
@L3 COUK1247
80
@V9 0
@YCHAPTER 14 - MUSS USER MANUAL
@G@RCHAPTER 14 - CREATION AND CONTROL OF PROCESSES@G
@V10 1 9 225
@T% 10
@BMUSS is designed as a system in which any process may create
other processes and act as their supervisor. It is thus possible
to extend the facilities of the basic system, by creating
additional/alternative supervisor processes. In this Chapter, the
facilities for creating and controlling processes are described.
@S214.1 PROCESS CREATION
@BProcess creation is achieved by calling a command CREATE.PROCESS.
Any process may use this command provided that it can supply the
username and password of an authorised user of the system. The user
will subsequently be charged for the resources used by the process.
The creating process becomes the supervisor of the created process,
and as such, it is allowed to use a special set of commands for
controlling the process.
@S214.2 SCHEDULING
@BWhen initially created, a process is in a suspended state, and is
not eligible for scheduling by the operating system. The supervisor
may activate the process using the FREE.PROCESS command, and the
process is then eligible for CPU time. The allocation of CPU
time is based on the priority level associated with the process
at the time of its creation. Sixteen levels of priority are
recognised by the system, ranging from the highest priority 0,
to the lowest 15. Charging for CPU time is related to the
priority (on a non-linear scale), so that a higher priority job may be
guaranteed an improved response time but at a considerably increased
cost. User processes normally run at priorities in the range 8 - 15,
and are assumed to have the following characteristics@
@Q 10
@
@M15  -  background jobs (will be run sometime)
@N14  -  normal batch
@N13  -  high priority batch
@N12  -  express batch
@N11  -  low priority interactive
@N10  -  normal interactive
@N 9  -  high priority interactive
@N 8  -  express interactive and operator work.
@
@
Different scheduling rules apply to batch and interactive processes.
A batch process, once started, is normally run to completion unless
pre-empted by the arrival of a higher priority batch process.
Interactive processes are timesliced, with the duration, cost and
frequency of timeslices dependent upon the priority level.
@S214.3 CPU TIME
@BThe maximum amount of CPU time to be made available to a process
is specified (in seconds) at the time a process is created. A process can arrang
e
to be interrupted after a specified amount of milliseconds has elapsed by
calling SET.TIMER. This provides the means of subdividing the
available time between various parts of a job. On being interrupted,
the timer is automatically set to the maximum amount of time
remaining. Note that a small amount of the total available time is
normally withheld by the system for the purpose of monitoring in the
event of using the requested amount of CPU time. The total amount
of CPU time used may also be read using the READ.TIMER command.
The accuracy of the timer, particularly with respect to the
microsecond timer, is subject to machine dependent tolerances.
@S214.4 INTERRUPTS
@BThe interrupt for time expired is actually one of four
types of interrupt trap which may be forced on a process. The reasons
for interrupt traps fall in the categories@
@Q 7
@
@MTrap 0  Hardware detected Fault conditions
@NTrap 1  Limit violations
@NTrap 2  Timer expired
@NTrap 3  Message interrupts or external interrupts
@N        (e.g. Pressing the break key on a terminal).
@
@
The action on the process of receiving one of these interrupts is to
obey a forced procedure call to a designated trap procedure. The
address of this procedure may be set using the command SET.INT.TRAP.
A procedure READ.INT.TRAP also exists for reading the address of the
trap procedure. The register of the process will be saved on the
stack before calling the procedure. Restoring these will continue
execution from the point at which the interrupt occurred.
@S214.5 COMMANDS
@
@
1) @JCREATE.PROCESS(II,II,II,I,I,P,I,I)
@BThis procedure creates a process of name P1 on behalf of the user
whose name and password are given in P2 and P3 respectively.
The process will run at the priority given by
P7 and will commence execution at the procedure P6.
@BThe maximum resources to be given to the process include a store
limit P4 specified in K words (integers), and a CPU limit of
P5 seconds.
@BThe facility is also provided for the system to inform the
supervisor when a process terminates. The parameter P8 defines a
channel number on which the supervisor is prepared to accept a
termination message containing the process identification. This
channel number is encoded as for send message.
@BThe identification of a process takes the form of a system process
number (SPN) and a process identifier (PID). These are returned in
PW1 and PW2 by the create process command, and must subsequently
be used by the supervisor when calling the procedures for controlling
the process.@
@
@
2) @JTERMINATE.PROCESS(I)
@BThis procedure is called whenever a process wishes to terminate.
The parameter states a termination reason, which will be sent to the
supervisor if a termination message was requested at create time.
Negative fault reasons imply termination due to a fault condition.
In particular, a reason of -100 implies that the process was aborted,
and the system will attempt to salvage whatever monitoring
information is available.@
@
@
3) @JKILL(II,I)
@BThis command may be called by a user to terminate the specified
process. It will only operate if the process is running under the
same user name as the current user (or if the current user is
privileged). The parameter P2 states a reason for killing the process.@
@
@
4) @JSUSPEND.PROCESS(I,I)
@BThis procedure may be called by a process' supervisor to suspend
execution of the specified process (P1 = SPN, P2 = PID).@
@
@
5) @JFREE.PROCESS(I,I)
@BThis command allows a process' supervisor to free it, and thus
make it eligible for scheduling (P1 = SPN, P2 = PID).@
@
@
6) @JLOOK.UP.PROCESS(II,II)
@BThis procedure finds the internal identification of the process
specified in P1. If P1 is zero, the identification of the current
process is returned. The second parameter states the machine in
which the process exists (0 implying the current machine). The
identification takes the form of an SPN in PW1 and a PID in PW2.@
@
@
7) @JREAD.PROCESS.STATUS(I)
@BThis procedure reads the status of the process with the
specified SPN. If this is negative, the current process is assumed.
The status information takes the form of@
@3
@U 21
@
@
               PWW1  Process name
               PWW2  Username
               PW1   SPN
               PW2   Process status, which is bit significant
                     with the following interpretation:
@
                     @O            @O
                     @O|      | | |@O
                             | |
                             |  --suspended
                              --waiting for message
                                (or after sending message)
@
               PW3   Priority
               PW4   PID
               PW5   Suspension reason (if any)
               PW6   Start time.
@
@
@0
@T% 50
8) @J@OC@OATALOGUE.@OPR@OOCESSES
@BThis procedure returns a segment containing information about all
the processes in the machine. The entries, which may be indexed
by SPN, occupy 32 bytes each and have the following format:@
@3
@U 12
@
          @O                                 @O
          @O| Process name (8 bytes)        |@O
          @O| User name ( 8 bytes)          |@O
          @O|         1 spare byte          |@O
          @O| Suspension reason (1 byte)    |@O
          @O|         Status ( 1 byte)      |@O
          @O|         Priority ( 1 byte)    |@O
          @O|         CPU time used         |@O
          @O|         Process identifier PID|@O
          @O|         Start time            |@O
@0
@
Each entry is 4 bytes unless stated otherwise. The total number of
entries is returned in PW1, and PW2 holds the segment number.@
@
@
9) @JSET.TIMER(I)
@BThis procedure allows a process to set its local CPU timer. The
parameter states the number of milliseconds
before the process will be interrupted (trap 2).
To allow for cases where this may be greater than the total
amount of CPU time remaining, the timer is set equal to the
smaller of the two.@
@
@
10) @JREAD.TIMER()
@BThis command returns in PW1 the amount of CPU time in seconds used by the
current process. The maximum available time in seconds is also returned in
PW2.
The time remaining in milliseconds in the local CPU time is returned in PW3.
The number of milliseconds used by the current process is returned
in PW4.@
@
@
11) @JFORCE.INT(I,I,I)
@BThis command may be called to force an external interrupt
(interrupt trap3) on a process. P1 and P2 specify the SPN and PID
of the process respectively, and P3 a reason to be passed to the
trap procedure. The command will only operate if the current process
is the creator of the process being interrupted or if the current user is
privileged.@
@
@
12) @JSET.INT.TRAP(I,P)
@BThis command sets the address of the specified interrupt trap
(P1 masked in the range 0 - 3) to be the procedure P2.@
@
@
13) @JREAD.INT.TRAP(I)
@BThis command reads the procedure address for the specified trap
and returns it in PW1.
@F
