Is there a way to disable file cache for a particular process ?
I have two process running A and B.
I want file opened by A to remain in cache.
and I don't want to enable file cache for B so It doesn't replace the file cached by process in the memory.
Is there a way to disable file cache for a particular process?Answer1:
None that I know of... the only option are global/device-specific:<ul><li>using -sync option with mount</li> <li>using <a href="http://www.linuxinsight.com/proc_sys_vm_drop_caches.html" rel="nofollow">drop_caches</a></li> </ul>
Even IF you could do what you ask for there is no guarantee that any other processes (C, D, E etc.) behaves in a way that "the file cached by process A in the memory" gets replaced...
<strong>UPDATE - after comments from OP ragarding performance:</strong>
Linux offers (as most modern OS) something called "memory-mapped file" - basically this is a way to access the file's contents in-memory... the OS assigns the file (depending on the given params) part of the address space and loads the content of the file into that address space (again: exact behaviour depends on the given params).
You would do this in Process A to achieve what you want...
Checkout the <a href="http://linux.die.net/man/2/mmap" rel="nofollow">
mmap API calls</a> for details.
Process B could use
fadvise() to direct the kernel to not cache data read from a given file descriptor.