GDSX Manual
LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual–134303
7-7
Transaction Flow
shared file (a terminal in this example) so that the threads do not interfere with each
other. The LINE^HANDLER task may queue the requests that come in and track any
request outstanding on the file so that when the request completes, a reply by way of
NOTIFY^IO^COMPLETION[X] returns the response’s IOCB address to the right
DEVICE^HANDLER task.
To the DEVICE^HANDLER the completion appears to be a standard file-system I/O
completion, with data returned in the buffer specified when the I/O was initiated and
standard Guardian condition codes set.
Transaction Flow
Before the basic structure of the LINE^HANDLER code is described, consider the
normal thread, or sequence of actions that occur for a complete transaction
(WRITEREAD-WRITE) initiated by an APPL requester application.
TSCODE passes the request to the DEVICE^HANDLER task handling the SU specified
by the requester. The DEVICE^HANDLER does datastream conversion and sends a
^WRITEREAD to the terminal file number, as shown in Figure 7-3.
TSCODE intercepts the message, determines that terminal file number is an ITC file
number, and passes the message to the ITC file for the appropriate LINE^HANDLER
task (in this example there is only one LINE^HANDLER task), which detects it as an
intertask message (E^ITC) when it calls WAIT^EVENT. Then the task calls ^LISTEN
to get the address of the IOCB for the message (@dh^iocb := ^LISTEN (0, 0, 1)).
When data is picked up from the IOCB, it is determined that the operation is a
^WRITEREAD, and a pointer to the IOCB is placed on a ^WRITEREAD IOCB queue,
where it remains until the transaction’s WRITE of the reversed string has been
completed. If the LINE file is free, a nowait ^WRITEREAD (the CPU, PIN prompt) is
sent to the LINE file (a terminal, in this case). A ^READUPDATE is posted on the in
Figure 7-3. LINE^HANDLER Example Message Flow
$A2
$A1
$A3
$RECEIVE
T1
T3
#LX
D^H Task
D^H Task
ITC File
T2
D^H Task
ITC File
ITC File
IN^QUEUE^
E^ITC
L^H Task
E^TIMEOUT
E^STOP
E^CAN
E^IMSG
$TC1
E^IOC
WT^IOCB
WT^RD^IOCB^LIST
CDT016
FILE^NUM/
Listener
Pseudo-
$RECEIVE
Pseudo-
$RECEIVE
Pseudo-
$RECEIVE