2
$\begingroup$

I was reading about the page cache Page cache - the cache in memory for files, but I couldn't find the answer to my question. Does the page table have anything to do with, or maintain any entries, for the page cache? My guess is no, despite the similar sounding name, as the page table only stores entries for text/code, stack, and heap segments for a process (i.e., virtual memory).

$\endgroup$
1
$\begingroup$

The only link is that they both operate with the same page size and, well, the same pages.

The reason is the mechanism of file access. You can request access to file via mapping its contents into memory space. In this case, the entire file isn't read into memory at once, instead, the page table is filled with inaccessible pages. Once application tries to access these pages, the actual file contents is read into memory.

So, the file cache stores individual pages of files, and this mechanism is described in the page cache article.

$\endgroup$
1
  • $\begingroup$ What you describe in the second paragraph is a memory-mapped file, right? Yeah...in that case the file is in virtual memory and so exists in the page table. But I was just thinking: for a process to access the file contents on a direct read/write (without memory-mapping the file), it must somehow copy the disk cache contents to its own address space (either on the stack or heap), right? And so the disk cache contents will be associated with an entry in the page table. Correct? $\endgroup$
    – flow2k
    Aug 23 '18 at 18:31

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .