GDSX Manual

LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual134303
7-16
LINE^HANDLER Procedure
A ^WRITEREAD to the IOP makes use of information in the IOCB pointed to by the
oldest IOCB address on the wt^rd^iocb^list. Here iocb.iocnt specifies the WRITE
count, and iocb.cnt specifies the maximum expected reply length.
The completion of I/O is determined with WAIT^EVENT, instead of with ^AWAITIO
as in the DEVICE^HANDLER.
Completion of LINE I/O
Example 7-5 shows the code for the LINE^IO^CMPLT subprocedure. Most of this
processing is described in “Transaction Flow” on page 7-7.
The IOCB STRUCT has a TCB address field, tcbaddr, that indicates the
DEVICE^HANDLER task associated with intertask request. Therefore, if the
LINE^HANDLER keeps track of the address of the IOCB for an intertask message, and
completes its processing of the message by calling NOTIFY^IO^COMPLETION with
the same IOCB as a parameter, TSCODE is able to complete the intertask
communication back to the DEVICE^HANDLER task.
When an I/O completes, the IOCB allocated by TSCODE and containing completion
information is called line^iocb. Line^iocb.iocnt contains the number of bytes of data
transferred during the operation. If the operation was a WRITEREAD, the iocnt field
holds the number of bytes read, even though in this operation’s IOCB on the queue,
iocnt holds the number of bytes to be written.
Example 7-4. WT^TO^LINE and WR^RD^TO^LINE Subprocedures
SUBPROC WT^TO^LINE;
BEGIN
INT .EXT BUF^PTR;
@BUF^PTR := WT^IOCB.BUFADDRX;
! MOVE TEXT INTO TASK'S OWN BUFFER
MSG^BUF ':=' BUF^PTR FOR WT^IOCB.IOCNT BYTES;
CALL ^WRITEX(LINE^FILE^NUM,MSG^BUF,WT^IOCB.IOCNT);
IF <> THEN CALL DEBUG;
END;
SUBPROC WT^RD^TO^LINE;
BEGIN
INT .EXT BUF^PTR, .EXT IOCB(IOCB^TEMPLATE);
WHILE ((WT^RD^IOCB^LIST[OLDEST] = 0D) AND ! SKIP CANCELED REQUESTS
(OLDEST <> NEWEST)) DO
CALL INCR^INDEX(OLDEST);
IF (OLDEST = NEWEST) THEN RETURN; ! NO OUTSTANDING REQUESTS
@IOCB := WT^RD^IOCB^LIST[OLDEST];
@BUF^PTR := IOCB.BUFADDRX;
MSG^BUF ':=' BUF^PTR FOR IOCB.IOCNT BYTES;
CALL ^WRITEREADX(LINE^FILE^NUM,MSG^BUF,IOCB.IOCNT,IOCB.CNT);
IF <> THEN CALL DEBUG;
END;