Presentation is loading. Please wait.

Presentation is loading. Please wait.

PAGE REPLACEMNT ALGORITHMS FUNDAMENTAL OF ALGORITHMS.

Similar presentations


Presentation on theme: "PAGE REPLACEMNT ALGORITHMS FUNDAMENTAL OF ALGORITHMS."— Presentation transcript:

1 PAGE REPLACEMNT ALGORITHMS FUNDAMENTAL OF ALGORITHMS

2 What is PAGING? Pages are certain fixed size memory block. Virtual Memory is the replacing physical memory with virtual pages. Pages written on secondary memory. Used when there is shortage of physical memory.

3 PAGE REPLACEMNENT When a page fault occurs, the operating system has to choose a page to remove from memory to make room for the page that has to be brought in. A page fault is an exception raised by the hardware, when a program accesses a page that is mapped in address space, but not loaded in physical memory.

4 Page Fault Handling A page to be removed can be selected randomly, or by using any algorithm. Similar Problems in: - Memory Cache - Webservers There are many algorithms available for replacing a page.

5 Optimal Page Replacement Algorithm Best possible algorithm but not real. Replace page which: - Never be needed again - Will be needed farthest point in future Non Real

6 LRU Algorithm LRU(Least Recently Used) assume pages used recently (arranged in linked list) will used again soon. R(Reference) and M(Modified) Bit Class 0:Not referenced,not modified Class 1:Not referenced, modified Class 3: referenced, not modified Class 4: referenced, modified Throw out page that has been unused for longest time on the basis of R and M bits. Modrately Efficient, not optimal.

7 FIFO Page Replacement Algorithm Pages in memory are maintained in a linked list (a queue). –The page at the head is the oldest one. –The page at the tail is the newest one. Algorithm: –When necessary, evict the page at the head of the list. Add the new page to the tail of the list. Rarely used in its pure form

8 The Second Chance Page Replacement Algorithm It takes care of oldest page which has been referenced. When it decides to remove a page –1. Looks to the head of the list –2. If head has R-bit as 1, then R-bit of head is cleared and it is put to the end. If R-bits of all pages in memory are set, then this algorithm is effectively same with FIFO

9 The Clock Page Replacement Algorithm Better than second chance. Page frames on a circular list in the form of a clock A hand points to the oldest page.

10 If a page fault occurs: –1. If R bit of page pointed to by hand is 0, then remove the page; Insert the new page to the same location, Advance the hand by one position in clockwise direction. –2. If R bit is 1, then hand is advanced by one position in clockwise direction, and R bit is set to zero. Repeat step 2 until a page whose R-bit is 0 is found. Then execute step 1.

11 The Working Set Page Replacement Algorithm The working set is the set of pages used by the k most recent memory references w(k,t) is the size of the working set at time, t

12 The Working Set Page Replacement Algorithm

13 The WSClock Page Replacement Algorithm

14 Conclusions Minimize the redundant access to secondary disc. Dynamic and Static Algos

15 THANK YOU ASHISH SHARMA (061222) DEEP CHANDRA GUPTA (061231)


Download ppt "PAGE REPLACEMNT ALGORITHMS FUNDAMENTAL OF ALGORITHMS."

Similar presentations


Ads by Google