New Page 1
Welcome to basicsofcomputer.com
 

Share This Free Knowledge With Your Friends:

Home » Virtual Memory in Operating System » Page Replacement Algorithm in Operating System

Page Replacement Algorithm in Operating System:

Definition and Explanation:

The algorithms used to select the page to be replaced are called page replacement policies. The main three policies are:

1. First-In First-Out (FIFO):

The First-in First-out policy removes the page that has been resident in memory for the longest time. It assumes mat such a page is no longer in use. It is also very simple to implement. In spite of being frequently required, the FIFO method, will periodically remove pages. It causes another early page fault.

Example:

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7

-

-

7

0

-

7

0

1

2

0

1

  2

3

1

2

3

0

4

3

0

4

2

0

4

2

3

0

2

3

  0

1

3

0

1

2

  7

1

2

7

0

2

7

0

1

In the above example, we have three empty frames and first three references (7,0,1) are brought in these frames. Now the next reference (2) replaces page 7 because it came first. The next reference is 0 that is already in the memory so no page fault occurs. This process continues as shown in the figure. Whenever a page fault occurs, we replace the page that entered the memory first of all.

2. Page Optimal Replacement:

This algorithm produces lowest page fault rate. It replaces the page that will not be used for the longer period of time.

3. Least Recently Used (LRU):

Least Recently Used policy replaces the page whose time since last reference is greater. This requires a time stamp (marker) recording for a page frame at the time of each reference. The selected page for replaced would then, have the oldest time. The overhead in such a system is that of maintaining all the time stamps (generally a linked-list) and the time taken to find the oldest value.

4. Not Recently Used (NRU):

Not Recently Used algorithm associates a page reference bit' with each page frame. This policy selects an interval of time during which the page reference bit is set to 1 if the page is referenced during this time. After the interval terminates, all the bits are reset and a new interval of time is set. Thus if a page has its page reference bit set to 1, it indicates that this page has been used during the current interval. The NRU policy simply selects for replacement any page with a page-referenced bit of 0.

5. LRU Approximation Algorithms:

There are three LRU approximation page replacement algorithms. All make use of a reference bit associated with each entry in the page table. Initially the reference bit is set to 0. When the page is accessed (either read or write), the reference bit is set to 1. After some time the bits are checked and from this we know which pages have been used since the last check.

1 Additional-Reference Bits Algorithm:

In this algorithm an S-bit byte for each page is kept in a table in memory. At regular time intervals, the reference bits for each page are shifted into the high-order bit of its 8-bit byte, shifting the other bits right 1 bit and discarding the low-order bit. Then the reference bit is cleared. These 8-bit shift registers contain the history for the page use for the last eight time periods. If a page was recently used,, the page will have a register like 10000000. If a page has not been used at all, it will have a register like 00000000. If the registers are interpreted as an unsigned integer, the page with the lowest number is the LRU page. If more than one page has the same LRU value then we can either swap all pages with that value or use a FIFO selection.

2. Second-Chance Algorithm:

This algorithm is a FIFO replacement algorithm with consideration given to the reference bit. When a page has been selected for replacement, its reference bit is inspected. If it is set to 0, then it hasn't been used recently and it is replaced. If the reference bit is set to 1, then it is given a second chance and move on to the next FIFO page. When a page is given a second chance, its reference bit is cleared and its arrival time reset to the current time. This can easily be implemented using a circular queue. If all reference bits are set to 1 then the algorithm degenerates to FIFO.

3. Enhanced Second-Chance Algorithm:

In this algorithm, the method is the same as for second chance but the reference bit and the modify bit are used as an ordered pair. This gives 4 classes of pages:

1. (0,0) - Neither recently used nor modified - best replacement choice.

2. (0,1) - Not recently used by modified - not quite as good as the page will need to be written out before replacement.

3. (1,0) - Recently used but clean - it will probably be used again soon.

4. (1,1) - Recently used and modified - it will probably be used again soon and it needs to be written out before replacement.

When a page replacement is called for, a page will belong to one of these four classes. The page selected is the first one encountered in the lowest non-empty class. So when we are looking for a page to replace, we may need to cycle through the circular array several times before we find a page to be replaced. First time through, if encounter a page in a class (1,x) then give a second chance and reset the reference bit. When a (0,x) class page is found (i) and if it is (0,0) then replace. If it is (0,1) then may mark it and look further to see if there is a (0,0).

Relevant Articles:

Introduction to Virtual Memory System
Demand Paging in Operating System
Page Faults/Segment Faults in Operating System
Page Replacement in Operating System
Page Replacement Algorithm in Operating System
Allocation of Frames in Operating System
Thrashing in Operating System
Working Set in Operating System
Page Size in Operating System
 
New Page 1

Basic Computer Science

   
» The Age of Information

» Types of Computer and Digital Age

» Input and Output Devices

» Storage Devices Of Computer

» Central Processing Unit

» Software: The Power Behind The Power

» Data Communication and Computer Networks

» The Nature Of Information

» The System Theory

» Transaction Processing System (TPS) and Management Information System (MIS)

» Decision Support System (DSS) and Executive Support System (ESS)

» Expert System (ES) and Office Information System (OIS)

 

Operating Systems

   
» Introduction to Operating System

» Introduction to Process Management

» Threads and CPU Scheduling

» Process Synchronization in Operating System

» Deadlocks

» Memory Management in Operating System

» Virtual Memory in Operating System

» File System Management in Operating System

» I/O and Device Management

» Security

» Linux Operating System

 

Database Management System

   
» Introduction to Database Systems

» Database System Architecture

» Database Administration and Database Development Process

» The Entity-Relationship Model

» Semantic Object Model

» Logical Database Design and Relational Data Model

» Normalization in Database

» Transformation of E-R Model into Relational Data Model

» Representing Semantic Object Model and Types of Semantic Object Model

» Physical Database Design

» Introduction to Structured Query Language (SQL)

» Implementation of Relational Database and Database Application Design

» Client Server Database Systems & Open Database Connectivity (ODBC)

 

Questions and Answers

   
» Basics of Information Technology

» Computer Architecture

» Data Communication

» Information Networks

» Fundamentals of the Internet

» Application and Uses of Computer

» Security, Copyright and The Law

» Windows Operating Systems

» Spreadsheet Software

» Process Management in CPU

» CPU Scheduling

» Process Synchronization

» Deadlocks

» Memory Management

» Database Systems

» Database System Architecture

» Database Administration and Database Development Process
 
 
New Page 1
 

Home                Dictionary                 Contact us                   About us                    Privacy policy                  Link to us                   Advertise

Copy right ©  2012