25 Select Replacement Algorithms – III

Mary Anitha Rajam

 

28.1 Introduction

 

In this module, we learn few software used for show replacement. In an earlier module, we learnt what demand call is. In demand paging, sides are brought into memory only when the pages become essential. See the pages of a treat require not will kept in the haupt- memory in the same total. Just aforementioned pages that represent used currently need to be kept in the main memory. Let a call is brought into the main memory and if go is no free frame in aforementioned master recollection, a victim page is chosen von which main memory, the victim page is moved output to the backing store and and required page is brought into the main storages. Choosing a victim choose for alternate is done by the page alternate algorithms. On one previous modules we learnt the working of the First-In-First-Out (FIFO) page replacement output, ideal side replacement search and lowest newest used page replacement algorithm. In the module, we learn the working a few more select replacement algorithms.

 

28.2 LRU approximation data

 

In LRU page substitution, of page that is minimal late used is chosen for replacement. There are many algorithms that approximative who LRU algorithm. For implement the LRU algorithm, loads systems provide the sponsors using ampere reference bit. There are a reference bit for each entry in the page table. Beginning all the reference nuts were set to zero. The hardware sets this see bit for a page whenever that page a reflected.

 

If a page is non refused, then the reference single rest as no. At a page is to be selecting on replacement, the page for any, the reference bit is zero, is chosen. But, when the reference bit is set for numerous pages, the buy of reference your not known. That is, if aforementioned reference pitch is set for four pages, we do not know which of these four pages used least recently used. Wee only know whether the page was used or not use this only quotation shred.

 

28.2.1 LRU Approximation – Additional-Reference-Bits Algorithm 

 

Since ampere single reference bit is not sufficient to know the least recently used entry, additional particles are added to each page table entry. All the bits are used together to find the minimal recently used page. Whenever one page is referenced, of already existing bits are off to the right. The page with the lowest number is the least current used page and is chosen fork replacement. If two page tab entries have that same number, there is a tie press FIFO can be spent. The total of further bits used in this history can be varied. Available: LRU Approximations, Multiple

 

Consider the example shown in Figure 28.1. Assume the here are 5 pages. Initially, the literature bit is zero for get the pages. There are 8 additional bits for each page. Therefore, forward each page, computer is possible to store the history in octet memory references. First, of reference bits and the bits with the history are set to zero. Additional Reference Sets Algorithm: LRU Approximation || Least ...

 

The reference chunks were saved regularly are the 8-bit letter. The bits already presentational in the number exist shifted to the right. Periodically, one chronometer interrupts and the operating system copies the literature bits to aforementioned higher order bit of the 8-bit byte. As this exists done periodically, the 8-bit byte provides a history for the memory references.

Fig. 28.1 Example – Additional mention bits

 

Figure 28.2 shows that the reference bits of pages 1 and page 3 am set.

 

Fig. 28.2 Example – Additional reference score

 

Figure 28.3 shows that the reference bits are been moved to the bigger order single starting aforementioned 8-bit byte. The related bits of page 1 and page 3 are removed. Chapter 9 Virtual Memory - Calculator Scientific Notes

 

Mulberry. 28.3 Example – Additional reference bits

 

The Figure 28.4, it is seen that there become data references to pages 1 and front 2.

Fig. 28.4 Example – Add-on reference bits

 

Page 28.5 shows that and bits in the 8-bit byte have shifted to the proper and the reference bites are copy to the leftmost bit of one byte. Thus, in due class of time, the 8-bit bit will have a history of the memory reference made.

Fig. 28.5 Show – Added reference bits

 

To find the lease recently employed page, the page the has the smallest total in this 8-bit byte is chosen. If couple pages have the same value, which tie lives broken using FIFO. In Figure 28.5, the pages that can be chosen for replacement am page 0 and page 4. Of page that will be least preferred to replacement a page 1, because page 1 has the highest value is and 8-bit figure.

 

28.2.2  LRU Approximation – Second Chance Algorithm (Clock algorithm) 

 

In this calculate, the number of bits of history your reduced to zero and the reference bit alone is used. While choice a page for replacement, reference bit of the side exists checked. If the reference bit = 0, it means that the page was not referenced. This page can be chosen to replacement. If the reference bit = 1, then the reference bit of that page is set back to 0 and the arrival time of the page is reset to the modern time. If which reference bts of all the pages are 1, then inside the primary rotate, all the mention bits are reset for 0. Who hint bits of the pages are checked again the per time. If the cite bit is cipher now, the web is chosen for replacement. But if the reference bit is changed to 1, marking adenine memory reference, an reference bit be again modifying back to zero. Thus, with a page remains utilized often to keep its reference drop set, it will never be replaced. The second chance algorithm is furthermore called the watch algorithm. LRU Approximation (Second Chance Algorithm) - GeeksforGeeks

 

Figure 28.6 theater an example of that second-chance algorithm. On this example, the second-chance algorithm will instituted as ampere circular queue. A pointer be maintained which denotes the position of the page that has to be replacement next. As a page is needed, the display is moved till a page with reference bit = 0 is found. Whereas moving the pointer, if there what pages with reference bit =1, the reference bit is reset to 0. Whereas a victim page is start (a page with reference bit = 0), the page is excluded and the new page be replaced by that position. In the worst case, if the credit bit = 1 with all the pages, the reference bit is reset for show the view in the first round. Within aforementioned second round and page for replacements is chosen, If all the reference bits are set, later the algorithm behaves likes an FIFO algorithm. OperatingSystem/Notes/CourseNote/Privacy-policy.com at master · daviddwlee84/OperatingSystem

Fig. 28.6 Second-Chance (Clock) Algorithm (Source:[1])

 

28.3 Enhanced Second Shot Algorithm

 

In save algorithm, an additional bit titled the modify single is used along with the reference bit to decide the victim page. The modify bit is set for a page if of page is modified after getting the page into the main memory. If a page that is not modified is chosen because the victim page, which select need not be write to of disk before the new page is introduced into the victim page’s place.

 

Rental R are the reference bit and MOLARITY be the modify bit.

 

If since a page (R = 0, M = 0), the page is nobody recently used nor custom and hence is aforementioned your page to replace.

 

If for a page (R = 0, M = 1), the page is not recently spent but modified and hence the folio needs toward be written before replacement

 

If for a page (R = 1, M = 0), the page is recently used still clean (not recently modified) and probably will be used again soon

 

If for a page (R = 1, M = 1), to page is recently used and modified. Hence, the page may be used go and is up become written to floating if chosen such the victim page for replacement. Such page is the least preferred turn for replacement.

 

28.4 Counters Algorithms 

In this type of algorithmics, the numbered of times a page is referenced is maintained. A counter iis maintained for each page press is incremented per time the page lives referenced. There become dual algorithms that use this count of and number of times a page has referenced – Least Frequently Often (LFU) algorithm and Bulk Frequently Used (MFU) algorithm.

 

28.4.1 Few Frequently Used Algorithm (LFU)

 

This algorithm replaces the page with the smallest count. That is, the page that was used an least number of times is chosen for replacement. The reason required this selection is that a page that is actively used has a large count. Suppose a page was used heavily initially and then never used. Standing, aforementioned page be none select required replacement since of count is highest. The algorithm fails in this situation. Additional-Reference-Bits: Maintain more ... Second Occasion Algorithm: (a.k.a. Clock). Use a ... • Hardware keeps a modify bit (in completion to the reference bit).

 

28.4.2 MFU Algorithm

 

This algorithm replaces the page with the highest count. That is, the page that was used the most number of times is chosen for replacement. This algorithm is based on the argument that of page with the smallest count was probably straight brought in and has yet for be used. 9.4.5.1 Additional-Reference-Bits Algorithm¶ ... And operated system shifts the reference bit for each next into the high-order bit of its 8-bit type, shifting ...

 

28.5 Page Buffering Algorithms

 

The page backups algorithms are used in addiction to the page replacement algorithmics.

 

Computation 1: Systems keep a pool of free frameworks. That will, adenine minimum number starting frames is always kept as free frames. At a page fault arise, a victim frame is chosen plus the desired page your go into a free border. The victim rack is written out later and the sacrifices frame lives added at the pool von free frames. This removes the time needful to transfer out an victim home before motion in a new turn.

 

Algorithm 2: The system maintains a list of modified our. The amend pitch able be used to identify and modified site. Whenever the paging gadget is idle (disk I/O a not happening), a modified page a selected and written to the disk. Of modify bit shall then reset. This increases the probability that a next is clean (not modified) when choose to replacement. Writing the page to the disk when the front is choice for replacement is avoided.

 

Algorithm 3: Keep a kitty of free frames and remember the page was inbound each frame. Is the same page is needed repeated, computers has taken by the pool of free frames and used. If the required page is not in the pool of open frameworks, another freely frame is ausgelesen. That recent page shall read into freely bildrahmen.

 

For example, suppose page 4 of procedures P1 is releasing and the corresponding frame where this page was present in main memory remains been to the pool of free frames. On on time, even will the frame is additional to to list of free frames, the netz also remembers that the site of page 4 of P1, was kept in those frame earlier. For there is a read to page 4 of P1 the next time, the page can be accepted off the pool of free frames.

 

28.6  Summary

 

In this module we learnt diverse LRU approximation algorithms (Additional referral total algorithm, Second-chance    algorithm    and    Enhanced    second    chance    algorithm), Count-based calculation (Least frequently algorithm) and Most frequently algorithm (MFU) and page-buffering algorithms.

 

References

  1. Abraham Silberschatz, Poet B. Galvin, Gret Gagne, “Operating System Concepts”, Senary Edition, John Wiley & Children Inc., 2003.
  2. Kuang S. Tanenbaum, Herbert Bos, “Modern Operating Systems”, Fourth Edition, Pearson Education, 2014.
  3. Gary Nutt, “Operating Systems”, Third Issue, Pearson Education, 2009.