4

How does Linux's Virtual Memory system handle the following case:
1 Process 1 maps one of its virtual page to physical frame 1.
2 Context switches to process 2.
3 Process 2 use many memory which make kernel swaps out frame 1 and replace with its own content.
4 Context switches back to process 1.

question 1 : How does process 1 knows that it's content of frame 1 is not in memory and needs to do a swap in?
question 2 : who update process 1's pagetable?

**new question : When a page is swapped out, Linux uses the corresponding PTE to store enough information to locate the page on disk again.so , if a page is swapped out by Linux kernel.how to update corresponding pagetables who are mapping the page?

Community
  • 1
  • 1
orain
  • 107
  • 6
  • This question probably belongs to the [Unix & Linux Stack Exchange](http://unix.stackexchange.com) Q&A. – abronan Nov 20 '13 at 15:24
  • 1
    Your questions imply a misunderstanding of virtual memory. Generally, a process has no idea which of its pages are mapped or not, and doesn't need to care. The kernel manages the page tables and provides each process with the illusion that it is the only process running and that all its memory and other resources are always available. – twalberg Nov 20 '13 at 15:50
  • When the kernel swaps out frame 1, it updates the corresponding page table entries. – ninjalj Nov 20 '13 at 16:54
  • When a page is swapped out, Linux uses the corresponding PTE to store enough information to locate the page on disk again.so , if a page is swapped out by Linux kernel.how to update corresponding pagetables who are mapping the page? – orain Nov 20 '13 at 17:53
  • @orain: the information to locate the page on disk is stored on the corresponding VMA. – ninjalj Nov 20 '13 at 18:30
  • @ninjalj thx for you response.i have got the answer.http://stackoverflow.com/questions/16581490/how-does-kernel-know-which-pages-in-the-virtual-address-space-correspond-to-a-s – orain Nov 21 '13 at 01:02

0 Answers0