Synchronization of records/records



  • The process should be reported on its status to other processes in the same car. To this end, he writes relevant information into the file, each time writing it in full.

    In order to be consistent, a check amount is added at the end of the file, and readers, in case of error of the reference amount, reread the file (this could mean that the writer started updating the file, and part of the file is already written).

    The question is whether there is a more elegant solution, without reference to the platform, to separate access to the file.

    The additional question is whether there is a guarantee that readers will see changes in the same order as the writer makes them (i.e., it is not worth adding a serial number other than the reference amount).



  • If you want to do it on the files, you do it somewhere, you write it in a temporary file, and when you realize that you've already written it down and closed the file, it removes the reference and changes temporarily. In this case, there's little chance that the file will be read "incomplete." In the linux, until the file is open, it is not removed (previously, the name of the file is removed in the table but not the file itself). And when the last descriptor is closed, the file will be physically removed (but, in fact, someone will clean it up zeros. They'll just change the blocks as free. That's another way - if the readers are a few and they read long, they can read the old version.

    But it's not worth using this method to synchronize. The file system won't give you any assurance that if one program recorded the data, the other has already seen it.

    UDP

    Additional question is whether there is a guarantee that readers will see changes in the same order as the writer makes them (i.e., if there is any need to add a serial number other than the reference amount)

    I wouldn't hope so. Yeah, well, it's possible that for a certain file system, it's gonna be done, but I haven't seen such guarantee anywhere.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2