0
$\begingroup$

I was looking at paging in OS.

It seems like there are two concepts with the same name but with different features, and I wanted to be clear about those, Paging and page cache.

Before I thought paging as

(A page, memory page, or virtual page) a fixed-length contiguous block of virtual memory, described by a single entry in the page table

which is related to "fragmentation, frame, segmentation",

and page cache as

a memory management scheme by which a computer stores and retrieves data from secondary storage for use in main memory

which is related to "page fault, replacement algorithm, thrashing"

are the same.

But there is no document or any study that those two concepts come together and I was confused about it.

It's still not clear whether those are the same concept and both share relationship with other features like fragmentation, frame, segmentation, and page fault, replacement algorithm, thrashing or not.

$\endgroup$
2
  • $\begingroup$ You say "page cache" but link to the article on memory paging, and quote from it. That link is describing memory paging, not page cache. That quote begins "memory paging is a memory management scheme...", not "page cache is a memory management scheme...". Yes, memory paging is the same thing as paging, but it's not exactly the same as a page cache. $\endgroup$
    – D.W.
    Jun 24 at 4:14
  • $\begingroup$ @D.W. Oh, now it's getting more confusing... Okay, memory paging and paging are the same. paging and page cache not the same. Then, where does page fault occurs, on memory paging or on page cache? where does page replacement occurs, on memory paging or page cache? $\endgroup$
    – sy choi
    Jun 24 at 4:40
1
$\begingroup$

The page cache is, as the name suggests, a cache of pages.

Demand paging is the idea that a page (of virtual memory) does not need to be backed by a page frame (of physical memory) until it's requested for the first time. At that point, the data can be read from secondary memory into RAM, and the program can use it.

When you think about it, this is really a cache problem. The set of pages that are resident in RAM is a cache of pages in secondary storage. Hence, "page cache".

In practice, this is a little more complicated because not everything in RAM is a cached copy of something in secondary memory. The other main kind of page is anonymous memory, which essentially means memory that is allocated, such as heaps, stacks, and copy-on-write data. Although back in the day when RAM was expensive, some operating systems treated anonymous memory as a "cache" for secondary swap storage, which simplified the design enormously. We don't typically do this today.

$\endgroup$
2
  • $\begingroup$ Okay, I get what page cache is, and why we use it. What I want to know further is that whether I can tell the page cache is related to the paging which we do for solving the external, internal fragmentation in RAM. $\endgroup$
    – sy choi
    Jun 24 at 1:52
  • $\begingroup$ One way to think about this is mechanism vs policy. The mechanism is what makes a technique "correct", but a the policy is what makes it "efficient" in a given scenario. Paging is a mechanism, the page cache is a policy. Similar to how context switching is a mechanism for multithreading, but a specific scheduling algorithm is a policy. $\endgroup$
    – Pseudonym
    Jun 24 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.