GDSX Manual
Intertask Communication Example
Extended General Device Support (GDSX) Manual–134303
E-6
USAMPLE3
 192.     Call ^ReadupdateX(Dolr^RCV,RCV^Buf,132);
 193.     End
 194.     Else
 195.     -- write the data message to our device
 196.     Call ^WriteX(Term^File^Num, Buffptr, RCV^Iocb.Iocnt);
 197.    End;
 198. 
 199.    -----
 200.    E^ITC -> ! an intertask message
 201.    -----
 202.    Begin
 203.    -- get the address of the IOCB
 204.    @ITC^Iocb := ^Listen (0,0,1);
 205.    @BuffPtr := ITC^Iocb.BufaddrX;
 206.    -- write the message to our device
 207.    Term^Buf ':=' Buffptr for ITC^IOCB.Iocnt Bytes;
 208.    Call ^WriteX(Term^File^Num, Term^Buf, ITC^Iocb.Iocnt);
 209.    -- tell our partner task that we are finished
 210.    Call Notify^IO^CompletionX(ITC^Iocb);
 211.    -- do a ^READUPDATE for the next ITC message
 212.    Call ^ReadupdateX(Rcv^ITC^Fnum);
 213.   End;
 214. 
 215.   -----
 216.   E^IOC -> ! from our device (terminal)
 217.   -----
 218.    Begin
 219.     -- get the address of the IOCB
 220.    @Dev^Iocb := ^LISTEN (0, All^Files, 0);
 221.    @BuffPtr  :=  Dev^Iocb.BufaddrX;
 222. 
 223.     If BuffPtr = ["ITC:"] Then Begin
 224.     -- our ITC message has been processed; our partner has
 225.     -- called NOTIFY^IO^COMPLETIONX so we reply to 
 226.     -- $RECEIVE and do another ^READUPDATE
 227. 
 228.     -- because the value of LastrcvIOCB is cleared in
 229.     -- SEND^ITC^MSGX, we have to provide the tag
 230.     -- as the fourth parameter to do a real reply
 231.     -- and to deallocate the IOCB
 232.     Call ^REPLYX(,,,Dev^IOCB.MsgTAG);
 233.     Call ^READUPDATEX(DOLR^RCV,RCV^BUF,132);
 234.    End
 235.    Else Begin
 236.     -- check for our partner task only the first time
 237.     If W^Fcbaddr = -1D Then Begin
 238.     -- find our partner task
 239.     If My^Dcb.Name = ["$GDSX.#TASK1"] Then
 240.      Term^Buf  ':=' "$GDSX.#TASK2"
 241.     Else
 242.      Term^Buf  ':=' "$GDSX.#TASK1";
 244.     Term^Buf^Len := 12;
 245.     W^Fcbaddr  := 0D;
 246.     W^Dcbaddr  := 0D;
 247.     If Error := Get^ITC^FCB(Term^Buf:Term^Buf^Len,
 248.           W^Fcbaddr,
 249.           W^Dcbaddr) Then
 250.      W^Fcbaddr := -1D;
 251.     End;
 252. 
 253.     If W^Fcbaddr > 0D Then Begin
 254.     -- the message that we wrote on our device completed,
 255.     -- so write the message to our partner task
 256.     ITC^Buf ':=' "ITC: " & Buffptr For Dev^IOCB.IOCNT Bytes;
 257.     @Fcb^Ptr := W^Fcbaddr;
 258.     Call Send^ITC^MsgX (Fcb^Ptr,
 259.          ITC^Buf,
 260.          (Dev^IOCB.IOCNT + 6),
 261.          0,
 262.          -1D,
 263.          1); -- write operation
 264.     End;
 265.    End;










