0
$\begingroup$

I am trying to understand the concept of NRU from the following link. I have got some problem in understanding the text below:

NRU page replacement Algorithm

If the hardware does not have these bits, they can be simulated as follows. When a process is started up, all of its page table entries are marked as not in memory. As soon as any page is referenced, a page fault will occur. The operating system then sets the R bit (in its internal tables), changes the page table entry to point to the correct page, with mode READ ONLY, and restarts the instruction. If the page is subsequently written on, another page fault will occur, allowing the operating system to set the M bit and change the page's mode to READ/WRITE.

I have bolded the text. I have two problems: Page fault occurs if the page is not in memory but the above text says that (a)the page fault occurs at the time of modifying or writing the page? I can’t understand that. (b) Also I cant understand the text “, allowing the operating system to set the M bit and change the page's mode to READ/WRITE.” What is meant by READ/WRITE? If we are setting the M bit then it should be WRITE mode only? Why the text says READ/WRITE mode. Somebody please guide me.

$\endgroup$
1
$\begingroup$

The idea is to mark a read/write page as read-only when loading it into memory (or after writing it out). If it is written to, a fault will occur. When handling the fault, the operating system looks at it's tables, and notices it should be writeable. So it can record it as "written to" (modified) in it's tables, make it read/write, and allow the operation to proceed. Later writes just add insult to injury, no need to keep track of them.

| cite | improve this answer | |
$\endgroup$

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.