GDSX Manual
DEVICE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual–134303
5-7
USKELEX Example Code
At different points the task may give up control to TSCODE, for example, when the task 
does a ^AWAITIO following a ^WRITEREAD, the task is suspended, but there is no 
actual exit from the DEVICE^HANDLER procedure. A task is stopped by TSCODE if 
TSCODE receives a message from SCF to stop the SU, if TSCODE receives a message 
from a requester thread to close the terminal to which it is mapped, or if the task stops 
itself through a call to STOP^TASK.
This simple example program behaves like a single-threaded process (although 
multithreaded operation is possible within a DEVICE^HANDLER task). In the loop, 
the first thing done is a ^READUPDATE (not a Guardian READUPDATE) on pseudo-
$RECEIVE, which always has a file number of 0.  Then there is logic to determine what 
kind of request has been picked up from pseudo-$RECEIVE. (The types of requests 
involved, while typical of a passthrough program, are example specific; other 
applications might have more message-oriented requests.) 
Datastream conversion is done at PROCESS REQUEST DATA in Figure 5-3, before 
issuing a ^WRITE or ^WRITEREAD to the IOP. After a ^WRITEREAD or ^READ 
there will be data coming back from the IOP.  Although this example does not perform 
incoming datastream translation, such processing could be included at the place in the 
figure marked PROCESS REPLY DATA. CONTROL and SETMODE messages 
picked up on the pseudo-$RECEIVE are simply passed on to the IOP. 
Although every one of the I/O procedures used is inherently a nowait operation, from the 
task’s point of view, the DEVICE^HANDLER uses waited I/O, because each of the I/O 
calls is followed immediately with a ^AWAITIO, effectively making it a waited 
operation. 
USKELEX Example Code
This subsection examines the USKELEX source code. A complete listing is shown in 
Appendix B. Example 5-1 shows the global declarations, which are typical for a user 
source file. Global data within the common^data block can be referenced and updated 
by both TSCODE and USCODE, while global data within the user^private data block 
can be referenced and updated only by USCODE tasks.










