Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Question about $flush

 
Layne Burleson_1
Regular Advisor

Question about $flush

I got a question from a programmer and could not answer him. Can anyone provide an answer to his question below?


Suppose I have a file, 1000 blocks allocated, end-of-file set to block 1000.
An exe pgm opens the file, and does block mode read/writes, all between blocks 1 --> 1000.
The program runs "forever", unless told to shutdown, and then it does a CLOSE

Is there any point in ever calling $flush ?
It would appear not ....
- no atributes have changed, at least I don't think so
- no record activity (all block mode i/o)
5 REPLIES
Hein van den Heuvel
Honored Contributor

Re: Question about $flush

Correct. No point in calling $FLUSH (but little or no harm either) if all you do is block IO write (SYS$WRITE) so a file which is fully allocated aready.

The FLUSH tells RMS to write any dirty buffers to disk.. but there are non if there is no record IO.
And FLUSH tells RMS to tell the XQP to update teh EOF pointer... which is already where it will be.

Cheers,
Hein.
Hoff
Honored Contributor

Re: Question about $flush

"It depends"...

Flush gets the memory caches sent to disk.

Writes do tend to get out to disk pretty quickly, given typical settings. But not always: see the RMS deferred write DFW setting, for instance. There can also potentially be cases where a multi-block write operation gets interrupted.

Recent versions of OpenVMS Alpha and OpenVMS I64 have added this buffer flush into rundown processing, though a hard process stop, hard system halt or hard power-down still won't see a flush. And might well interrupt a multi-block write sequence.

If you wanted to add support for a consistent on-line backup -- which can be a good idea for applications that run forever -- you'd probably look to use $flush, seize up the application I/O processing just during a copy, then resume... (And you could implement a "flush fence" where I/Os to blocks that have been copied to the backup can pass through and I/Os above the flush block are held, but that's probably not worth it for a 1000 block transfer. If this is a far bigger file...)

It's also possible that your programmer might be indirectly asking you about what sort of recovery processing is expected. If you have a site policy and a default minimum shutdown time set, you might poll for the shutdown logical name, for instance, and use that to trigger a flush...
Hein van den Heuvel
Honored Contributor

Re: Question about $flush

More likely the programmer is simply confused between the Unix / C-rtl semantics for (f)write and (f)flush ( and fsync) and the RMS semantics for SYS$WRITE and SYS$FLUSH.

Unix/C and RMS Record IO may and will buffer.

RMS Block-IO will not.

Burleson, please confirm.

Cheers,
Hein.
Layne Burleson_1
Regular Advisor

Re: Question about $flush

Hein & Hoff, My programmer has indicated that your answers have satisfied his question. He actually sent that back to me just after Hein's 1st comments. Thanks again for your help.
Layne Burleson_1
Regular Advisor

Re: Question about $flush

The programmer has indicated that the answers above helped him. Thanks again.