An asynchronous operation is an operation that, once initiated,
executes "off to the side" and need not be completed before other
operations can begin to execute. Asynchronous operations are
common in symbiont applications because a symbiont, if it is
multithreaded, must handle concurrent I/O operations.
One example of a user routine that performs an asynchronous
operation is an output routine that calls the $QIO system service
to write a record to the printing device. When the user output
routine completes execution, the I/O request queued by $QIO might
not have completed. In order to synchronize this I/O request,
that is, to associate the I/O request with the service request
that initiated it, you should use the following mechanism:
1. In making the call to $QIO, specify the astadr and iosb
arguments. The astadr argument specifies an AST routine to
execute when the queued output request has completed, and the
iosb argument specifies an I/O status block to receive the
completion status of the I/O operation. Step 3 describes some
functions that your AST routine will need to do.
2. Have the user output routine return the status PSM$_PENDING.
3. Write the AST routine to perform the following functions:
a. Copy the completion status word from the I/O status block
to a longword location that you will specify as the status
argument in the call to PSM$REPORT.
b. Call PSM$REPORT. Specify as the request_id argument the
request identifier that was supplied by the print symbiont
in the original call to the user output routine.