Guardian Programmer's Guide

Table Of Contents
Using Nowait Input/Output
Guardian Programmer’s Guide 421922-014
4 - 3
Applying a Nowait Operation on a Single File
I/O operations initiated by the procedures listed below execute in parallel with your
process when invoked on a file opened for nowait I/O. You must complete each of
these calls by a separate call to the AWAITIO[X] procedure if the I/O operation is
against a file opened for nowait I/O.
Applying a Nowait Operation on a Single File
The simplest case of a nowait operation is that of a single I/O operation against one
file. In other words, multiple I/Os are not permitted to run concurrently against this file,
nor are nowait operations performed against other files.
First of all, you need to open the file for nowait I/O. You do this by putting a nonzero
value in the fifth parameter (nowait) of the FILE_OPEN_ procedure call. The nowait
parameter specifies how many outstanding nowait I/O operations can concurrently
exist against the file when identified by the returned file number. To allow only one
nowait operation at a time, set this value to 1 as shown in the example below:
NOWAIT^DEPTH := 1;
ERROR := FILE_OPEN_(DATAFILE:LENGTH,
FILENUM,
!access!,
!exclusion!,
NOWAIT^DEPTH);
IF ERROR <> 0 THEN ...
After opening the file, you can issue an I/O operation against the file:
BYTES := 512;
CALL WRITEX(FILENUM,
BUFFER,
BYTES);
IF <> THEN ...
CONTROL SETMODENOWAIT (for other than disk files)
CONTROLBUF
LOCKFILE UNLOCKFILE
LOCKREC UNLOCKREC
READ[X] WRITE[X]
READLOCK[X] WRITEREAD[X]
READUPDATE[X] WRITEUPDATE[X]
READUPDATELOCK[X] WRITEUPDATELOCK[X]
Note. When performing a nowait write operation, it is important that you do not overwrite your
write buffer between the WRITE[X] or WRITEREAD[X] procedure call and the corresponding
AWAITIOX procedure call. If you do modify the buffer in this period, then you cannot be sure
which data actually gets written.