GDSX Manual

LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual134303
7-11
E^ITC
E^CAN, cancellation of an intertask message
E^STOP, a request to stop this LINE^HANDLER task
These literals are declared in DCCBDECS(EVENTS). See Figure 7-3 on page 7-7.
E^ITC
The E^ITC branch of the CASE statement handles an intertask message detected by
WAIT^EVENT. ^LISTEN is called to get the address of the IOCB for the message. If
the operation type for the request is ^WRITEREAD, the IOCB address is put on a
^WRITEREAD IOCB queue, and if that IOCB is the only one on the queue, the task
knows the LINE object is free, and a ^WRITEREAD is sent to the LINE file.
If the operation type for the request is a ^WRITE, the task knows, because of requester
and LINE^HANDLER design, that the preceding operation on the LINE object was the
corresponding ^WRITEREAD of the requester’s ^WRITEREAD-^WRITE transaction,
and the ^WRITE is sent to the LINE file. After either type of operation is handled,
another ^READUPDATE is posted on the queue addressed by in^queue^file^num.
E^IOC
The E^IOC branch of the CASE statement handles a LINE file I/O completion detected
by WAIT^EVENT. ^LISTEN is called to get the address of the IOCB for the message.
The task assumes that only WRITE or WRITEREAD operations are processed. In
either case, the file-system error code is passed back to the DEVICE^HANDLER task
with a call to NOTIFY^IO^COMPLETION.
If the operation was a WRITEREAD, the IOCB buffer and I/O count are also passed
back. If the operation was a WRITE, the corresponding and preceding WRITEREAD’s
IOCB address is taken off the ^WRITEREAD IOCB queue (because the
^WRITEREAD-^WRITE transaction is complete from the LINE^HANDLER’s
perspective), and if the queue is not empty, a ^WRITEREAD is sent to the LINE file.
Finally, the LINE IOCB is deallocated.
E^CAN
The E^CAN branch of the CASE statement deals with LINE^HANDLER task cleanup
after cancellation of an intertask message by a user exit other than LINE^HANDLER
and DEVICE^HANDLER. In this example it is assumed that only the ^WRITEREAD
sent from a DEVICE^HANDLER task to the LINE file will ever need to be canceled; a
^WRITE would not be outstanding for any appreciable period.
If such a user exit calls ^CANCEL to cancel a ^WRITEREAD, the call is passed to
TSCODE, which is aware of outstanding I/O because of its role as intermediary between
the Guardian file system and the user exits. TSCODE finds the IOCB associated with
the request. If the iocb.state is equal to 2 (io^itc^queued), TSCODE deallocates the
IOCB. If the iocb.state is equal to 6 (io^active), TSCODE links the IOCB to the
LINE^HANDLER task’s TCB and puts the IOCB in a canceled state so that the
LINE^HANDLER task can delete it. TSCODE then sends the LINE^HANDLER task
an E^CAN event, indicating that an intertask request has been marked as canceled.