Virtual memory and paging

I am doing some exercises to understand how virtual memory and paging works, my question is this:

Suppose we use paged memory with pages of size 1024 bytes, the virtual address space is 8 pages, but physical memory can contain only 4 frames. Replacement Policy - LRU.

  • What is the physical address in main memory corresponding to virtual address 4096? and how do you achieve this result?
  • Same as question 1, but with virtual address 1024
  • When accessing a word on page 0, a page error occurs, what page frame will be used to get virtual page 0?

Page Image

My test:

What I have received so far for questions 1. and 2. determines the address in the table (attached as an image) for the corresponding pages. So, for example, I will map the virtual address 4096 on page 4 and 1024 on page 1, is that right?

+4
source share
1 answer
  • I would find the page that the URL links to first. The first page starts at 0, and the last byte at 1023, the second page starts at 1024, etc. So, 4096 is the beginning of the fourth page in the virtual memory table. According to the “Presence on the main memory bit”, this table is unloaded, so we look at the “page frame” column to see which page the main memory is on. The table says on page 01, which is 1 in binary format. In real memory, each page is still 1024 bytes, so the index of page 1 will be found at the physical address of 1024.

  • Similar to 1

  • 4 pages mean page numbers in binary format 00, 01, 10, 11. If the page is not currently in use, this will be the first page to be filled after a page error.

+1
source

Source: https://habr.com/ru/post/1307398/


All Articles