Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 13
Avoiding Unnecessary Cache Flushes to
Unstructured Files
Avoiding Unnecessary Cache Flushes to Unstructured Files
You can avoid unnecessary cache flushes to unstructured files in the same way as for
any other file by using function 152 of the SETMODE procedure as shown in the
following code fragment:
LITERAL AVOID^FLUSH = 152,
DONT^FLUSH = 1;
.
.
CALL SETMODE(FILE^NUM,
AVOID^FLUSH,
DONT^FLUSH);
IF <> THEN ...
By default, an unaudited file always has its cache flushed when you close the file. By
using SETMODE 152, you avoid this unnecessary overhead in the following situations:
After the close, the file remains open for writing by your process or some other
process.
The close is not the last close on a file that was opened with a nonzero sync-depth
value.
To be effective, SETMODE 152 with param1 set to 1 should be performed for each
open of the file. Any open that does not perform SETMODE 152 with param1 set to 1
causes a cache flush when it closes the file.
For optimal performance, you should not use SETMODE 152 with param1 set to 1 if
the file is to be closed by all openers at about the same time. This is because, in such
a case, all buffers in the cache are flushed serially by the last opener rather than in
parallel by each opener.
For audited files, SETMODE 152 is unnecessary. The NonStop TM/MP product
automatically avoids unnecessary flushes. See the NonStop TM/MP Reference
Manual for details.
Closing Unstructured Files
An unstructured file can be closed in the same way as any other file, by using the
FILE_CLOSE_ procedure:
ERROR := FILE_CLOSE_(FILE^NUM);
IF ERROR <> 0 THEN ...
When a process terminates, any files that the process still has open are automatically
closed.