Sign in with
Sign up | Sign in
Your question

Is a disk cache what a lowly developer expects it to be?

Tags:
  • Hard Drives
  • Cache
  • Linux
  • Storage
Last response: in Storage
Share
April 4, 2011 8:21:01 AM

Hi all,

I develop tests of an application which among other things write data to files, sync that data to disk with sync() (man 2 sync on Linux) and subsequently opens the same file, reads its contents and make sure that the read file contains the expected data.

What I see is that I have timing issues with when data is written to a file and when it is read, in other words, I sometimes manage to read data before it has actually been written, although the sequence of the operations are 1)write 2)read.

Linux supposedly flushes the OS buffer cache in response to a sync() call. This leaves the disk cache as a possible culprit, so my question is:
- Is the cache of a disk shared by all applications accessing the cache?

This is what a cache is to me as a software developer but perhaps you hw guys have another opinion?

Thanks

More about : disk cache lowly developer expects

a c 392 G Storage
April 4, 2011 12:06:40 PM

It's all the same, a cache buffers reads and/or writes to a slower device. If it's working properly and the data in the cache is not dirty it will read from cache, otherwise it should read from the device to get the correct data.
April 5, 2011 4:41:06 AM

That's what I thought and that's what I hoped for. Thanks for clearing that out!
!