Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Ah-ha, that makes sense. Thanks. However, the file is still being written; when I run the above code in the background, and execute ls --time-style='+%d-%m-%Y %H:%M:%S' -l several times, I see test.txt has a modification time that is updated every second. Hence the file is being updated, so the kernel buffers written by write() must be being flushed. This is what I want to control: the frequency at which this flush happens. How can I do this? Commented Dec 22, 2020 at 19:40
  • The kernel maintains an illusion that files are written to and read from a disk or some other medium, and that the files (with associated timestamps) are created on said medium. I say illusion, because all this is sped up by caching data in the page cache. The semantics are the same even if the actual write is delayed. Thus the modification times are also "faked", and do not necessarily reflect the true flush time. Commented Dec 22, 2020 at 20:24
  • Right, ok; thanks. I really want to be able to learn more about the automatic flushing of the buffers from a learning point-of-view, but it seems this might be quite hard. Do you know how this happens: what process/thread is doing it,and how I can watch it on my system? As I say, I don't have a pdflush and don't know what is doing it on my system... Commented Dec 22, 2020 at 20:30
  • I added a link to my answer. Commented Dec 23, 2020 at 6:39
  • Thanks. I've updated my question with my additional findings/experiements for easy reference for others. Commented Dec 23, 2020 at 17:02