GDSX (Extended General Device Support) Manual
DEVICE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual—529931-001
5-11
The DEVICE^HANDLER Procedure
Within the main loop of the DEVICE^HANDLER (see Example 5-3 and Example 5-6), a 
buffer of size buf^size is requested from the byte-addressable extended buffer pool. 
The buffer holds a message read from the pseudo-$RECEIVE file. Because tasks are 
swapped in and out, I/O cannot be done from buffers within a task’s data stack. 
Instead of declaring local variables for message buffers, I/O buffer space is obtained 
from the global memory pools.
The 10 in the GETEXTPOOL call indicates the extended buffer pool. The buffer 
allocated is pointed to by @rcv^buf. The take^over variable is used when running this 
example as a process pair, and is discussed later in this section. 
Then ^READUPDATE is called on dolr^rcv, which represents the pseudo-$RECEIVE 
file set up by TSCODE. (The pseudo-$RECEIVE file is indicated by value 0 for all 
DEVICE^HANDLER tasks.) Because this is a single-threaded routine, the 
^READUPDATE is followed by a ^AWAITIO on dolr^rcv with no timeout specified. 
Then there is a check to see what kind of operation is being requested. If the condition 
code is equal, ^AWAITIO completed normally, and either a WRITE, a READ, or a 
WRITEREAD came in. ^AWAITIO gives the WRITE count (rqstr^wt^ct) that the 
requester specified, and ^RECEIVEINFO gives the READ count (rqstr^rd^ct) specified 
by the requester and the request type (rqst^type).  
Example 5-3. Reading and Decoding Requests
!===============================================================
! Device^Handler Procedure MAIN ENTRY POINT begins here
!===============================================================
 WHILE (1) DO
 BEGIN
 @RCV^BUF := GETEXTPOOL(10,BUF^SIZE); !EXT BUFFER POOL
 IF @RCV^BUF = 0D THEN CALL DEBUG; !(BYTE ADDRESSABLE)
 @E^RCV^BUF := @RCV^BUF;
 TAKE^OVER := FALSE;
 CALL ^READUPDATEX(DOLR^RCV,RCV^BUF,BUF^SIZE);
 IF <> THEN CALL DEBUG;
 CALL ^AWAITIOX(DOLR^RCV,@RCV^BUF,RQSTR^WT^CT);
 IF = THEN ! (CCE) NORMAL COMPLETION
 CALL ^RECEIVEINFO(,,,,RQSTR^RD^CT,RQST^TYPE)
 ELSE IF > THEN ! (CCG) SYSTEM MSG RECEIVED
 BEGIN
 IF RCV^BUF[0] = -32 THEN
 RQST^TYPE := CTRL
 ELSE IF RCV^BUF[0] = -33 THEN
 RQST^TYPE := SET^MD
 ELSE
 CALL DEBUG;
 END
 ELSE
 CALL DEBUG; ! (CCL) ERROR
Note. The USKELEX and USKELEXC example programs include very little error-handling 
logic, because error-handling code depends on the application requirements, and extensive 
error-handling code would detract from the overall design focus of this tutorial. Adequate error 
handling, however, must be included in applications designed for actual production.










