Checking file data status

Hello,
When reading a file (either from C code or Linux commands such as cp), its data is saved in the memory to optimize the next read. That is to say, in the next time one will need to read the file, it will be on the memory and thus disc accessed will be saved. However, if the operating system needs memory space, it may get rid of the file data in the memory. Then, the next read of this file will require disc access.

What I need to know is what is the status of this data in a specific time. Is it in the memory (so reading it will be very fast) or not (then reading it will be slow as it will be reread from the disc). Is there any way to query this details?

Thanks a lot!
Not at the application level. You would need to add functionality into the page cache to do that.
Unless you are writing your own OS, you are wasting your time. The OS already optimizes disk access very well.

Hope this helps.
Topic archived. No new replies allowed.