From what i've learned, the HW is responsible for setting the accessed and dirty bits in the PTE of a process, and the OS is responsible for turning them off. My question is why?
The first part, i think is because only the HW is preforming the page table walk and it's a good opportunity for it to set them (because by doing the page walk or checking the tlb, it implies that a process wanted to access/write to a page).
Does the second part have something to do with the fact that the OS manages the page cache and all the paging to the disk go through it?

  • 3
    $\begingroup$ The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! $\endgroup$ – Raphael Jul 16 '18 at 16:12
  • $\begingroup$ You're likely to get an answer sooner if you ask this on the Linux & Unix stack. $\endgroup$ – Kyle Jones Jul 25 '18 at 3:06
  • $\begingroup$ @KyleJones, it isn't Linux specific, but a question about hardware and software handling of paging (or virtual memory in general). $\endgroup$ – vonbrand Aug 1 '18 at 13:19

Why? Because this design works pretty well and meets the requirements, and most alternative don't or would be more expensive or slower. In particular, this division of responsibilities lets the system implement a suitable page replacement policy for virtual pages in a way that is relatively efficient.

When asking a "why is it done this way?", it's often helpful to try to imagine some concrete alternative way of doing it, and then analyze the advantages and disadvantages of the current method compared to that alternative. You haven't listed a specific alternative, so it's hard to be a lot more specific. But for instance if you tried to do it all in software (so the OS has all responsibility), without the hardware managing the accessed or dirty bits, that would be very difficult: the only methods I can think of for doing that are clunky and will cause many context switches and thus will slow down the system a lot.


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.