GDSX Manual

LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual134303
7-12
E^STOP
The E^CAN event is detected by this example’s call to WAIT^EVENT. The
CANCEL^ITC SUBPROC is then called. In order to delete the IOCB for the
outstanding ^WRITEREAD to the LINE file, the LINE^HANDLER task needs to find
the IOCB marked for cancellation, but there is no way to use ^LISTEN to find such an
IOCB as there is to use ^LISTEN to find IOCBs for intertask messages, messages from
$RECEIVE, and I/O completion messages. Because this example’s LINE^HANDLER
task maintains a queue of IOCBs representing outstanding ^WRITEREAD requests
from the DEVICE^HANDLER tasks, the queue is scanned to find IOCBs put into a
canceled state by TSCODE, and these are released by calling
NOTIFY^IO^COMPLETION. TSCODE recognizes the IOCB passed as belonging to
the canceled request.
Then the LINE^HANDLER task calls ^CANCEL on any WRITEREAD actually sent to
the LINE file. After canceling a WRITEREAD to the LINE file, if there is another
queued request, it is written to the file. Finally, another ^READUPDATE is posted on
the queue addressed by in^queue^file^num.
E^STOP
The E^STOP branch of the CASE statement handles requests from TSCODE to stop the
LINE^HANDLER task. If E^STOP is detected by WAIT^EVENT, the
LINE^HANDLER message buffer is deallocated, and the TSCODE-supported
STOP^TASK procedure is called.
LINE^HANDLER Example Code
A complete listing of source code file USKELEX is in Appendix B. The source and
object files used for this example are exactly the same as those used for the
DEVICE^HANDLER example program.
The customized LINE^HANDLER procedure, while included in USCODE, was never
called in the tutorial of Sections 4 and 5. Customized user exits for the
DEVICE^HANDLER and USER^STOP were described in those sections; here the
LINE^HANDLER code is discussed.
LINE^HANDLER Procedure
There are three parameters passed by TSCODE to the LINE^HANDLER, as shown in
Example 7-1. The first, line^file^num, contains the Guardian file number used for I/O to
the file that this task is to manage. The LINE^HANDLER does not open this file.
When the LINE object is started, TSCODE opens the file, assigns line^file^num for the
task to use, and passes this number as a parameter when the call to LINE^HANDLER
creates the task.
The second parameter is internal^line^no. Each LINE^HANDLER task has exactly one
line control block (LCB) associated with it. The value of internal^line^no is an index
used to find this task’s LCB in the array of LCBs. This is discussed further in the
Inspect exercise later in this section.
The third parameter is in^queue^file^num, which contains a file number for a TSCODE-
maintained $RECEIVE-like queue of intertask messages sent to this task from all