0% found this document useful (0 votes)
35 views3 pages

Comparison of Page Replacement Algorithms

Notes

Uploaded by

dikshitss0405
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Comparison of Page Replacement Algorithms

Notes

Uploaded by

dikshitss0405
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Page Replacement Algorithm

Page replacement algorithms are the techniques using which an Operating System decides
which memory pages to swap out, write to disk when a page of memory needs to be allocated.
Paging happens whenever a page fault occurs and a free page cannot be used for allocation
purpose accounting to reason that pages are not available or the number of free pages is lower
than required pages.
When the page that was selected for replacement and was paged out, is referenced again, it has
to read in from disk, and this requires for I/O completion. This process determines the quality of
the page replacement algorithm: the lesser the time waiting for page-ins, the better is the
algorithm.
A page replacement algorithm looks at the limited information about accessing the pages
provided by hardware, and tries to select which pages should be replaced to minimize the total
number of page misses, while balancing it with the costs of primary storage and processor time
of the algorithm itself. There are many different page replacement algorithms. We evaluate an
algorithm by running it on a particular string of memory reference and computing the number of
page faults,
Reference String
The string of memory references is called reference string. Reference strings are generated
artificially or by tracing a given system and recording the address of each memory reference.
The latter choice produces a large number of data, where we note two things.
 For a given page size, we need to consider only the page number, not the entire address.
 If we have a reference to a page p, then any immediately following references to
page p will never cause a page fault. Page p will be in memory after the first reference;
the immediately following references will not fault.
 For example, consider the following sequence of addresses − 123,215,600,1234,76,96
 If page size is 100, then the reference string is 1,2,6,12,0,0
First In First Out (FIFO) algorithm
 Oldest page in main memory is the one which will be selected for replacement.
 Easy to implement, keep a list, replace pages from the tail and add new pages at the
head.

RAJENDRA KUAMR MAHTO INFORMATION TECHNOLOGY DSPMU RANCHI Page 1


Optimal Page algorithm
 An optimal page-replacement algorithm has the lowest page-fault rate of all algorithms.
An optimal page-replacement algorithm exists, and has been called OPT or MIN.
 Replace the page that will not be used for the longest period of time. Use the time when a
page is to be used.

RAJENDRA KUAMR MAHTO INFORMATION TECHNOLOGY DSPMU RANCHI Page 2


Least Recently Used (LRU) algorithm
 Page which has not been used for the longest time in main memory is the one which will
be selected for replacement.
 Easy to implement, keep a list, replace pages by looking back into time.

Page Buffering algorithm

 To get a process start quickly, keep a pool of free frames.


 On page fault, select a page to be replaced.
 Write the new page in the frame of free pool, mark the page table and restart the process.
 Now write the dirty page out of disk and place the frame holding replaced page in free
pool.

RAJENDRA KUAMR MAHTO INFORMATION TECHNOLOGY DSPMU RANCHI Page 3

Common questions

Powered by AI

A reference string is used to evaluate page replacement algorithms by providing a sequence of memory page accesses. This string helps determine the sequence of page faults that occur based on algorithmic behavior. By analyzing the reference string, we can compute the number of page faults for different algorithms, thus assessing their efficiency .

The main objectives while evaluating a page replacement algorithm are minimizing the total number of page misses, balancing the costs of primary storage, and processor time of the algorithm itself. The efficiency is determined by the time waiting for page-ins due to a page fault—the lesser the time, the better the algorithm .

The OPT algorithm's lowest page fault rate depends on perfect knowledge of future page accesses, making it impractical for real-time application where future data is unknown. Practical challenges include the need for foresight into memory access patterns, which are dynamic and unpredictable in real-world systems. Despite being ideal for analysis, this requirement limits its use to theoretical assessment .

The LRU algorithm selects the page that has not been used for the longest time, using historical data on page access. Its practical application involves maintaining access order, unlike OPT, which theoretically chooses the page not needed for the longest future period, requiring perfect knowledge of the future. LRU is implementable in actual systems, providing a balance between performance and feasibility, whereas OPT remains an ideal benchmark .

A system's page size affects the reference string by determining the granularity of memory references into page numbers. A larger page size results in fewer distinct page numbers within a reference string, typically reducing the number of page faults. Conversely, smaller page sizes can increase the page fault rate by requiring more pages to cover the same data span but allowing for better memory utilization granularity .

Belady's anomaly in FIFO leads to increased page faults as memory size increases, contrasting with the general expectation that more memory reduces faults. This anomaly does not occur in LRU algorithms because they adapt based on historical access patterns, ensuring that pages not recently used are replaced first regardless of increased memory allocation. LRU's adaptation to dynamic workloads provides more stability in page fault behavior as memory size changes .

Page Buffering offers advantages in systems with frequent page faults by reducing waiting time for I/O operations. Traditional methods may suffer delays due to the need to write and read pages during faults, while Page Buffering uses a free frames pool to quickly load incoming pages and defer writes, leading to faster process resumption and enhanced system responsiveness .

The Page Buffering algorithm optimizes page replacement by maintaining a pool of free frames, which enables quicker page swaps. On a page fault, it allows for the new page to be written in an available frame from this pool, immediately restarting the process. This reduces downtime and the time taken to write the dirty page back to disk, providing operational efficiency .

The FIFO algorithm replaces the oldest page in memory, relying on no knowledge of future accesses, which can result in sub-optimal performance and high page faults. In contrast, the OPT (Optimal) algorithm selects the page that will not be used for the longest period of time in the future, minimizing page faults by using foresight into memory usage. OPT is more effective theoretically as it results in the lowest possible page-fault rate, but it is impractical in real-world scenarios due to the requirement of future knowledge .

The FIFO page replacement algorithm operates by replacing the oldest page in main memory when a page fault occurs. Pages are managed through a list structure where pages are added to the head and removed from the tail. The advantage of FIFO is its simplicity and ease of implementation. However, its major limitation is the possibility of replacing frequently accessed pages, leading to high page faults, especially in cases of Belady's anomaly .

You might also like