Is the data in a memory mapped file guaranteed to be hidden sequentially?

I am trying to implement a file storage mechanism that contains several records with a variable size in one file with the guarantee that the recordset will always be restored to a consistent state, even if the system failed at a hardware level.

So far, every circuit I came across comes down to writing data sequentially. Some data will be added to the end of each record, which confirms that the record is complete. However, if the data is not necessarily written to the disc sequentially during blurring, then confirmation data can be written before the content data.

There are two obvious ways, but both are undesirable:

  • Discard the contents, then write a confirmation and rinse it. Adding an additional flush may degrade performance.
  • Include the checksum in the confirmation (you will need to read the contents to confirm that it is valid).

I use C # for Windows (32 and 64-bit) and a .NET memory card.

+6
recovery paging memory-mapped-files
source share
2 answers

This is too low and OS for C #. try using the Windows API from C and read the API specifications carefully.

+1
source share

Have you tried using FileOptions.WriteThrough on the underlying file stream? This may help as it disables buffering. Other ideas are to save a separate file containing confirmations as the last recorded offset, if it does not match your file size (due to a power failure, for example), you can simply truncate it at that size

0
source share

All Articles