The interrupt handler is a special
procedure of the process, devoted to
completing the I/O request after an interrupt occurs.
This procedure
is never called explicitly.
Instead, MPE/iX invokes the interrupt handler when
a software interrupt occurs, possibly from the middle of a statement.
The procedure declaration can be
either without parameters, or have a single
INTEGER parameter into which MPE/iX puts the file number.
The file number parameter of the software
interrupt handler is useful if there
are several files sharing the same software interrupt handler
procedure and some require special handling.
For example, each file may have a different buffer address passed to
IOWAIT.
MPE/iX automatically disables software interrupts and CONTROL-Y
traps when it jumps to the interrupt handler.
A call to IODONTWAIT or
IOWAIT is needed to finish the I/O request.
The I/O request can be completed
immediately,
so IOWAIT and IODONTWAIT
will work the same way. (IOWAIT
always completes immediately.)
Check the condition code
(a good idea after any intrinsic call). CCG means
the interrupt occurred because of an End-Of-File condition.
If a CCE is returned, the process has a record.
It can be processed here, or a flag can
be set to indicate that
the record has been received and should be handled
during the normal non-interrupt processing.
Often, at this point, the next software interrupt read is set up
by performing another FREAD, if the process wants to
continue to see new records written to this message file.
The FREAD does
not have to be done here
and could be performed elsewhere during normal
processing.
The process may not want to issue any FREAD at all,
if the command just received was to stop immediately and
terminate.
The last statement in the interrupt handler must be a call
to FINTEXIT.
This allows the process to pick up where it left off when
the interrupt occurred,
enable CONTROL-Y traps, and optionally leave software
interrupts enabled or disabled.
If this call is omitted, the process may never get back
to where it was before the interrupt.
Exiting with software interrupts enabled
is usual,
but the process may leave them disabled if the record needs
special processing
and it does not want any additional interrupts until it is
completed. At that time it needs to call FINTSTATE
to enable interrupts.