Q166: Second chance page replacement policy

Second chance page replacement policy: Each page maintains a reference bit. Pages are checked in FIFO order, if the page encountered has a set bit, it is cleared and the page is placed at the end and the next page is checked. If the page encountered has unset reference bit, then it is taken out for replacement. Below is the illustration (Note that pages are being checked in FIFO order and not from top to bottom).

second_chance

Question 166:  If the next access is made for page ‘1’ then ‘2’, which page(s) will be replaced?

Options:

  • 3, None
  • 3, 4
  • 2, 3
  • 2, 4

 

Solution: First, 4 will be given a second chance, and 2 will be replaced for 1. Then when 2 comes next, 4 will be replaced. The correct answer is the last one.

Q102: Why do we need access control bits in page table entries?

Question #102: Why do we need access control bits in page table entries?

  1. Because the pages might be shared.
  2. Some pages might contain executable code, which is read-only.
  3. Some pages contain data, so there shouldn’t be any instructions that should execute from that memory space.

Options:

A. All of the options 1, 2 and 3 are correct.

B. Only option 1 is correct.

C. Only options 2 and 3 are correct.

D. Only options 1 and 2 are correct.

Solution: The correct answer is C. Executable code should only be read-only and any attempt to write on that space should be trapped. Similarly any data should be read or written, but any attempt to execute from that address space should be trapped!

Q73: Shared pages between two processes

Question 73: Consider the following situation where process X and Y’s page table is shown. VPFN refers to virtual page frame number in virtual memory address space and PFN refers to page frame number in physical memory.

page_table\

Which of the following statement is true?

  1. Physical page frame number 4 is shared between virtual PFN 1 of Process Y and virtual PFN 3 of Process X.
  2. Physical page frame number 0 is shared between virtual PFN 2 of Process Y and virtual PFN 3 of Process X.
  3. Physical page frame number 4 is shared between virtual PFN 1 of Process X and virtual PFN 3 of Process Y.
  4. No physical page is shared.

Solution: Page table of Process X maps its VPFN 3 to PFN 4, and page table of Process Y maps its VPFN 1 of Process Y to PFN 4. The correct answer is option 1.

Q39: Bits for page table entry (PTE)

Question 39: A machine has 48-bit virtual address and 32-bit physical addresses. Pages are 8 KB. How many bits are needed for the page table entry?

Options:

  1. 20 bits
  2. 24 bits
  3. 34 bits
  4. 48 bits

 

Solution:

For an 8 KB page, 14 bits would be used for offset within the page (2^14 = 8K). Hence, out of 48, remaining 48-14 = 34 bits would be needed for the page table entry. Therefore, the correct answer is option 3.