Q164: Page faults using FIFO page replacement policy

This is in continuation with Q79.

Using FIFO page replacement policy, assume that the page request follows the following order:

3, 2, 1, 0, 3, 2, 4, 3, 2, 1, 0, 4

Question 164: If there are total 4 page frames in the system, how many page faults will be there?

Options:

  1. 0
  2. 6
  3. 9
  4. 10

Solution:  Following will be the sequence of pages in memory, pages in red will be the ones which will be replaced.

Newest Page 3 2 1 0 0 0 4 3 2 1 0 4
  3 2 1 1 1 0 4 3 2 1 0
  3 2 2 2 1 0 4 3 2 1
Oldest Page 3 3 3 2 1 0 4 3 2

Hence, the correct answer is the last option. This is an example of Belady’s anomaly, that is, increasing number of page frames results in increase in the number of page faults.

Q79: Page faults using FIFO page replacement policy

Using FIFO page replacement policy, assume that the page request follows the following order:

3, 2, 1, 0, 3, 2, 4, 3, 2, 1, 0, 4

Question 79: If there are total 3 page frames in the system, how many page faults will be there?

  1. 0
  2. 6
  3. 9
  4. 10

Solution: Following will be the sequence of pages in memory, pages in red will be the ones which will be replaced.

Newest Page 3 2 1 0 3 2 4 4 4 1 0 0
  3 2 1 0 3 2 2 2 4 1 1
Oldest Page 3 2 1 0 3 3 3 2 4 4

Hence, the correct answer is option 3.

Q78: Kernel vs User memory

Question 78: Kernel also requires memory for storing its code and various other segments, processes specific data etc. How should this kernel memory be implemented?

  1. Same as user process i.e. Virtual memory because kernel is just like another process.
  2. Same as user process i.e. Virtual memory because VM system provides easy security and sharing mechanism.
  3. It should not be implemented as virtual memory because kernel pages shouldn’t be swapped out as they are critical to system’s working.
  4. It should not be implemented as virtual memory because kernel pages shouldn’t be intermingled with processes pages. It requires separate contiguous memory.

Solution: Kernel pages perform critical functions and shouldn’t be swapped out. Example, page fault handler is part of kernel, if the code for it is not itself present in memory and a page fault occurs for some user process then there is no way to deal with it. Hence, the correct answer is option 3.

Q11: Access pattern in memory

Question #11: Consider the hypothetical scenario where there are 4 pages in physical memory and 3 processes are running simultaneously on 3 different processors. Following is the access pattern which repeats over and over again.
Access pattern of P1: {a, b, b, c, b}, {a, b, b, c, b}, …
Access pattern of P2: {p, q, q, q, p}, {p, q, q, q, p}, …
Access pattern of P3: {x, x, x, y, z}, {x, x, x, y, z}, …
Which of the following is a sensible choice of 3 pages which could always remain in memory?

 

Options:

  1. b, q, x

  2. a, b, x

  3. b, p, x

  4. Can’t say

 

Solution:

Process P1 accesses ‘b’ the most, P2 accesses ‘q’ the most, and P3 accesses ‘x’ the maximum times. So if these 3 pages are present always and the remaining pages in memory can be used for other accesses. Hence, the correct answer is option 1.