3.5.3 Internal File Buffers

By default, MS-DOS collects data in internal file buffers before writing it to a drive. This improves system performance by reducing the number of times MS-DOS accesses the drive hardware. MS-DOS usually holds the data from a write operation until the buffer is filled or the program closes the file. While held in a buffer, data is inaccessible to the program.

If necessary, a program can transfer a file's written data to a drive immediately by using Commit File (Interrupt 21h Function 68h). If a program must ensure that data written to a file is always committed to the drive immediately, it can open or create the file by using Extended Open/Create (Interrupt 21h Function 6Ch) and specifying the OPEN_FLAGS_COMMIT option. This option causes MS-DOS to commit the file after each write operation, without individual calls to Commit File.

A program can commit the data in all internal file buffers in one step by using Reset Drive (Interrupt 21h Function 0Dh). This function is typically used by CTRL+C Handler (Interrupt 23h) to ensure that the contents of all open files are updated before the program terminates. Note, however, that this function does not update the directory entries for the files, so changes to time, date, and file size may not be recorded.