NRU: Page fault on writing?

  • Thread starter zak100
  • Start date
  • #1
zak100
Gold Member
462
11

Summary:

Hi,
I am trying to understand the concept of NRU from the following link. I have got some problem in understanding the text below:
https://www.informit.com/articles/article.aspx?p=25260&seqNum=3

Main Question or Discussion Point

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.

Zulfi.
 

Answers and Replies

  • #2
anorlunda
Staff Emeritus
Insights Author
8,582
5,460
LOL your question invokes an age-old joke among programmers, the "write-only-memory". Just the concept used to send programmers rolling on the floor with laughter.

Look at it this way. If a page has only been read, then the page entry can be given up without writing anything back to main memory. However, as soon as the page is modified, the page entry can not be given up before the cache contents are written back to main memory.

What are all the possible states of a page?
How would you keep track of those states using bits?
When does the OS care what the state is?
 
  • #3
zak100
Gold Member
462
11
Hi my friend, thanks for your reply.

Your reply was LOL for me because I asked one question and now you are asking 3 questions.
<What are all the possible states of a page?>
4.
00, 01, 10, 11
<
How would you keep track of those states using bits?>

Maybe by storing in some array or just by looking at the 2 bits.

<When does the OS care what the state is?>
At the time of page fault because all the memory frames might be full and we are requesting a page which is not in main memory, so we have replace a page in the frame with a page from virtual memory.

My problem not yet solved.

Zulfi.
 
  • #4
nsaspook
Science Advisor
940
1,356
LOL your question invokes an age-old joke among programmers, the "write-only-memory". Just the concept used to send programmers rolling on the floor with laughter.
Programmers might laugh but hardware guys design it.

https://en.wikipedia.org/wiki/Write-only_memory_(engineering)
In 1972, WOM, an antithesis of read-only memory (ROM), was introduced as an inside practical joke perpetrated by Signetics.[1] However, it was soon recognized that this concept actually describes certain functionalities in microprocessor systems.[2]
 
  • Haha
Likes anorlunda

Related Threads on NRU: Page fault on writing?

Replies
8
Views
6K
  • Last Post
Replies
9
Views
3K
  • Last Post
Replies
5
Views
4K
  • Last Post
Replies
7
Views
4K
Replies
5
Views
23K
  • Last Post
Replies
5
Views
8K
Replies
4
Views
3K
  • Last Post
Replies
8
Views
10K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
5
Views
602
Top