0
25kviews
Calculate no. of page faults and page hits for the page replacement policies FIFO, Optimal & LRU for given string4 , 7, 3, 0, 1, 7, 3, 8, 5, 4, 5, 3 , 4,7. state which one is best in above example.

Mumbai University > Computer Engineering > sem 4> computer organization and architecture

Marks: 10M

Year: Dec16

1 Answer
0
694views

Paging:

  • Paging is a memory-management scheme which allows the physical address of a process to be non-contiguous.
  • The concept of paging is used to remove the problem of fragmentation. Here we are able to allocate physical memory to the process in a non-contiguous manner wherever memory is available.
  • Paging avoids external fragmentation and the need for compaction. Paging is done by breaking the physical memory into fixed size blocks called frames and breaking the logical memory into blocks of same size called pages.
  • When a process is being executed, the corresponding pages are fetched and loaded into the available memory frames.

FIFO page replacement:

In FIFO page replacement,

when a page is needed to be replaced, we select the oldest page.

4 7 3 0 1 7 3 8 5 4 5 3 4 7
4 4 4 0 0 0 3 3 3 4 4 4 4 7
7 7 7 1 1 1 8 8 8 8 3 3 3
3 3 3 7 7 7 5 5 5 5 5 5
F F F F F F F F F F F F

page fault=14

page hits=2

Optimal Page replacement:

Here, when a page replacement is needed, it looks ahead in the input queue for the page frame which will be referenced only after a long time. The page with the longest reference is swapped.

4 7 3 0 1 7 3 8 5 4 5 3 4 7
4 4 4 0 0 0 3 3 3 4 4 4 4 4
7 7 7 1 1 1 8 8 8 8 3 3 3
3 3 3 7 7 7 5 5 5 5 5 7
F F F F F F F F F F F F

page fault=12

page hits=2

LRU page replacement:

This method uses the recent past as an approximation of near future. We replace the page which has not been referenced for a long time in the past.

4 7 3 0 1 7 3 8 5 4 5 3 4 7
4 4 4 7 3 3 3 0 7 8 8 5 5 4
7 7 3 0 0 0 7 8 5 5 4 4 3
3 0 7 7 7 8 5 4 4 3 3 7
F F F F F F F F F F

page fault=10

page hits=4

Best page replacement algorithm:

LRU page replacement algorithm seems to be the best page replacement algorithm as"the no. of page faults are minimum as compared to any page replacement algorithm.

Please log in to add an answer.