GDSX Manual
Extended General Device Support (GDSX) Manual–134303
5-1
5
DEVICE^HANDLER Example, Design
The previous section described how to run and manage a simple DEVICE^HANDLER
example program. This section contains a description of the environment of an
executing DEVICE^HANDLER task, and an analysis of the design of the
DEVICE^HANDLER example, including the typical structure used by a
DEVICE^HANDLER for input, processing, and output to the IOP.
Environment of an Executing DEVICE^HANDLER
Task
The purpose of TSCODE is to provide a multithreaded, fault-tolerant shell for USCODE
procedures. To provide these services, GDSX was implemented in such a way that it
resembles a small, multitasking operating system.
In Guardian programming you have a source file and an object file, and the object file
runs under the operating system. In GDSX programming you have a
DEVICE^HANDLER procedure, which is like a normal Guardian source file, and a
DEVICE^HANDLER task, which is like a normal Guardian object file. The
DEVICE^HANDLER task runs under GDSX.
Figure 5-1 illustrates what a running DEVICE^HANDLER task looks like in this
example’s environment. (D^H represents the running DEVICE^HANDLER task within
the GDSX environment.) TSCODE, which surrounds the D^H tasks and includes the
monitor and listener tasks, provides a multithreaded, fault-tolerant environment for
USCODE.
TSCODE opens I/O devices on behalf of the tasks. When the example application
APPL opens a terminal under a GDSX process, TSCODE receives the OPEN request,
opens the terminal, and then assigns to the device a file number to be used by the task
that will be created to manage the device. The number assigned is the actual Guardian
file number for the device. (However, if a device is preconfigured under a line, a
different, ITC file number is assigned—see the LINE^HANDLER example in Sections 6
and 7.)
TSCODE then calls the DEVICE^HANDLER procedure, thereby creating a
DEVICE^HANDLER task to manage the terminal. The first parameter supplied when
calling the procedure is the file number (filenum), which the DEVICE^HANDLER is
to use when communicating with the I/O device.