GDSX (Extended General Device Support) Manual

Design and Development
Extended General Device Support (GDSX) Manual529931-001
2-98
USAMPLE Example Program
When the task finishes processing the request and calls NOTIFY^IO^COMPLETION,
the IOCB is delinked from the DEVICE^HANDLER task’s TCB and the ITC file’s FCB
and is queued on the DEVICE^HANDLER task’s completed I/O list. Also, the IOCB’s
state is changed to 5 (pending). Finally, the DEVICE^HANDLER task’s IOC event is
posted. This is the same action that takes place when a Guardian I/O operation
completes.
Canceling a Request
When a DEVICE^HANDLER task cancels an I/O that is linked to its tcb.iocbh, the
^CANCELREQ procedure locates the associated IOCB just as it would for a Guardian
file I/O. Rather than calling CANCELREQ, however, ^CANCELREQ determines the
state of the IOCB and acts as follows:
If the iocb.state is 2 (io^itc^queued), TSCODE delinks and deallocates the IOCB.
Note that when the LINE^HANDLER calls ^LISTEN, it may be the case that no
IOCB is returned.
If the iocb.state is 6 (active), TSCODE delinks the IOCB from the
DEVICE^HANDLER task’s TCB and links it to the LINE^HANDLER’s TCB in
tcb.iocbh/iocbt. This is done so that the IOCB is guaranteed to be deallocated
even if both the DEVICE^HANDLER task and the LINE^HANDLER are terminated.
The IOCB’s state is set to io^canceled. Finally, the LINE^HANDLER’s E^CAN
event is canceled.
USAMPLE Example Program
The sample LINE^HANDLER provided in the installed subvolume file USAMPLE was
used to validate and debug the Envoy interface facility, and is not intended for
production use. It does, however, show one possible approach to implementing an
Envoy interface and can serve as the basis for a viable production LINE^HANDLER.
USAMPLE can be run as a converted or an unconverted process. See Running a
GDSX Application on page 3-1.
The installed subvolume file ULHDECS is used when compiling USAMPLE.
ULHDECS was created by modifying DCCBDECS. Seven words have been added to
the DCB structure:
!2! STRING poll^addr[0:3];
!2! STRING sel^addr [0:3];
!1! INT iocbaddr; !Current request
!1! INT poll^inx; !Polling Index Into Poll list
!1! INT sel^inx; !Select Index Into Poll list
Therefore, this example program must be started with EXTSUSIZE is equal to 7 or
greater. Notice that the procedure USER^INITIALIZE checks to be certain that this is
the case; if it is not, an error message is generated, and the GDSX process is stopped
by a call on ^TERMINATE.