Memory Management
Page Cache
A part of the disk is maintained in physical RAM known as Page Cache. This cache is used to improve the performance of the system. A read or write from the physical memory is faster than from the disk.

The page cache consists of actual physical pages in RAM(not virtual), the contents of which correspond to the blocks on a disk. The size of this cache can grow dynamically, increases if more memory is available or shrinks for any memory pressure.
Whenever a read() call is performed by the process, the data is read from the Page cache. If required pages are found, then its called a cache-hit, otherwise its a cache-miss, during which block I/O operations are performed and the data is copied from the disk to the cache and read again.
When the process does a write() call, there are three strategies available.
- A write() operation directly writes data to the disk. This strategy is called no-write, as shown below. If the data need to be read, it needs to be fetched into the cache first and then perform a read operation. This is not efficient strategy and is rarely used.

- In the second strategy, the data is written to both the cache and the disk. This way, a further read operation will get a cache-hit. Though this is good, the overall time to copy to the disk undermines having a cache in the first place.

- In the third case, data is written to the cache first. The backing store is not updated yet. Instead, the written to pages are marked as dirty and are added to the dirty list. Periodically, dirty pages are written back to the disk in a process called writeback, bringing the on-disk copy in line with the on-cache copy. The pages are no longer dirty after this happens. This strategy is used in Linux.

