Quote:
Originally Posted by zama
Buffer is something where data is there in memory but yet to be flushed to disk . The data will be flushed to disk by bdflush daemon periodically or we can do it manually by running sync command .
Cache on the other hand is program/data which is loaded into memory but is retained in memory so that if is needed again , it will be quickly available.
|
I'm pretty sure your distinction between buffers and cache is completely wrong.
I don't fully understand the distinction myself, but I think the underlying issue behind the distinction is page alignment.
Caching in a paged OS is simplest when an entire page (normally 4KB) is aligned on a page boundary in the file itself, in physical memory of the cache and in the virtual address mapping that uses it (user address space if it is a mapped page or kernel address space for other forms of file I/O).
I believe cache is used for caching things that can be handled as full aligned pages and buffers are used for caching things that can't.
That should be orthogonal to the distinction between data that has been modified and is awaiting write back and data that is kept in case it will be read again.