GDSX Manual

Design and Development
Extended General Device Support (GDSX) Manual134303
2-93
USAMPLE Example Program
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.
Opens are associated with devices by the simple expediency of assigning an openid
equal to the address of the associated DCB. Consequently, the procedure
USER^START merely sets openid to @DCB, clears dcb.link and dcb.iocbaddr, and
returns.
USER^STOP
The procedure USER^STOP must be able to handle the termination of both
LINE^HANDLER tasks and DEVICE^HANDLER tasks; the subprocedures
STOP^LINE and STOP^DEVICE^HANDLER handle these cases.