Guardian Programmer's Guide

Table Of Contents
Guardian Programmer’s Guide 421922-014
4 - 1
4
Using Nowait Input/Output
This section discusses how to do I/O operations without having the process wait for
completion of the operation. A process that does not wait for I/O operations to finish is
said to be using nowait I/O.
This section uses examples to show the different ways in which you can use nowait
I/O. It discusses how to write programs that:
Perform a single nowait I/O operation against just one file
Perform multiple I/O operations that run concurrently against just one file
Perform multiple I/O operations that run concurrently against more than one file
A complete program is included that shows how to use nowait I/O to time out I/O
operations.
Overview of Nowait Input/Output
Normally, when a process issues an I/O request, the process waits for the operation to
finish before continuing. The process enters the wait state (see Section 16, Creating
and Managing Processes, for a discussion of process states) and some other process
gains access to the CPU. Instead of having your process wait for the operation to
finish, however, you can write your program to initiate the I/O operation and then
continue processing while the I/O operation finishes. Completion of the I/O is detected
later by a call to the AWAITIO[X] procedure.
You should use the AWAITIOX procedure to complete nowait READX, WRITEX, and
WRITEREADX calls. You should use the AWAITIO procedure to complete nowait
READ, WRITE, and WRITEREAD calls.
You can also use the FILE_COMPLETE_ procedure to complete nowait calls that you
would otherwise complete by calling AWAITIO[X]. The FILE_COMPLETE_ procedure
has special features; for example, you can use it to complete nowait I/O on any file
from a predefined set of files, which can include both Guardian files and Open System
Services (OSS) files. The FILE_COMPLETE_ procedure and its companion
procedures, FILE_COMPLETE_SET_ and FILE_COMPLETE_GETINFO_, are
discussed later in this section.
Figure 4-1 compares waited I/O with nowait I/O.