GDSX (Extended General Device Support) Manual

LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual529931-001
7-13
E^STOP
task an E^CAN event, indicating that an intertask request has been marked as
canceled.
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 Section 4, DEVICE^HANDLER Example, Running and
Managing and Section 5, DEVICE^HANDLER Example, Design. 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.