what other block replacement technique can be used and is proved to be the ideal
What are the Page Replacement Algorithms?
This lesson will innovate yous to the concept of page replacement, which is used in retentiveness management. You volition understand the definition, demand and diverse algorithms related to page replacement.
A figurer system has a limited corporeality of memory. Calculation more retention physically is very costly. Therefore most modern computers utilise a combination of both hardware and software to let the calculator to address more retentivity than the corporeality physically present on the system. This actress memory is actually called Virtual Retentiveness.
Virtual Memory is a storage allocation scheme used by the Memory Management Unit(MMU) to compensate for the shortage of physical memory past transferring information from RAM to disk storage. It addresses secondary memory as though information technology is a part of the main memory. Virtual Memory makes the retentiveness appear larger than actually nowadays which helps in the execution of programs that are larger than the physical memory.
Virtual Memory can exist implemented using two methods :
- Paging
- Segmentation
In this weblog, we will learn nigh the paging part.
Paging
Paging is a procedure of reading information from, and writing data to, the secondary storage. Information technology is a memory management scheme that is used to retrieve processes from the secondary memory in the course of pages and store them in the primary memory. The master objective of paging is to dissever each process in the form of pages of fixed size. These pages are stored in the main memory in frames. Pages of a process are only brought from the secondary memory to the master memory when they are needed.
When an executing process refers to a page, it is first searched in the main retentiveness. If it is not nowadays in the main memory, a folio fault occurs.
** Page Fault is the condition in which a running process refers to a page that is non loaded in the master memory.
In such a case, the Bone has to bring the page from the secondary storage into the master memory. This may cause some pages in the main memory to be replaced due to limited storage. A Page Replacement Algorithm is required to decide which page needs to be replaced.
Page Replacement Algorithm
Page Replacement Algorithm decides which page to remove, besides called swap out when a new folio needs to be loaded into the main memory. Page Replacement happens when a requested page is not nowadays in the chief memory and the available infinite is not sufficient for allocation to the requested page.
When the page that was selected for replacement was paged out, and referenced over again, it has to read in from disk, and this requires for I/O completion. This process determines the quality of the folio replacement algorithm: the lesser the time waiting for folio-ins, the better is the algorithm.
A page replacement algorithm tries to select which pages should be replaced so as to minimize the total number of page misses. In that location are many different page replacement algorithms. These algorithms are evaluated past running them on a particular cord of retentiveness reference and computing the number of page faults. The fewer is the folio faults the better is the algorithm for that situation.
** If a process requests for page and that page is plant in the main memory then information technology is called page hit, otherwise folio miss or page error.
Some Page Replacement Algorithms :
- Kickoff In First Out (FIFO)
- Least Recently Used (LRU)
- Optimal Page Replacement
Commencement In First Out (FIFO)
This is the simplest page replacement algorithm. In this algorithm, the Bone maintains a queue that keeps track of all the pages in memory, with the oldest folio at the front and the most recent page at the back.
When there is a need for page replacement, the FIFO algorithm, swaps out the folio at the front of the queue, that is the folio which has been in the memory for the longest fourth dimension.
For Instance:
Consider the page reference string of size 12: 1, two, 3, iv, 5, i, 3, 1, 6, 3, 2, 3 with frame size 4(i.e. maximum iv pages in a frame).
Total Page Fault = 9
Initially, all four slots are empty, so when 1, 2, iii, 4 came they are allocated to the empty slots in order of their arrival. This is page mistake as one, ii, three, 4 are non available in memory.
When 5 comes, it is not bachelor in retention so page fault occurs and it replaces the oldest page in retentiveness, i.due east., ane.
When 1 comes, it is not available in memory so page error occurs and it replaces the oldest page in memory, i.e., 2.
When 3,1 comes, it is available in the memory, i.east., Page Hit, and so no replacement occurs.
When 6 comes, information technology is not bachelor in memory and then page fault occurs and it replaces the oldest page in memory, i.e., iii.
When iii comes, information technology is not available in memory so page error occurs and it replaces the oldest folio in memory, i.e., iv.
When two comes, it is non available in retention and then folio mistake occurs and information technology replaces the oldest page in retentiveness, i.e., 5.
When 3 comes, information technology is available in the memory, i.east., Folio Hit, so no replacement occurs.
Page Error ratio = 9/12 i.east. full miss/full possible cases
Advantages
- Simple and easy to implement.
- Depression overhead.
Disadvantages
- Poor performance.
- Doesn't consider the frequency of use or last used time, only replaces the oldest page.
- Suffers from Belady's Anomaly(i.e. more page faults when we increase the number of folio frames).
Least Recently Used (LRU)
Least Recently Used page replacement algorithm keeps track of page usage over a short period of time. It works on the thought that the pages that take been most heavily used in the past are most likely to be used heavily in the future also.
In LRU, whenever folio replacement happens, the page which has not been used for the longest amount of fourth dimension is replaced.
For Example
Total Page Error = 8
Initially, all iv slots are empty, then when 1, ii, 3, iv came they are allocated to the empty slots in club of their arrival. This is page error as 1, 2, 3, iv are not bachelor in retention.
When 5 comes, information technology is not available in memory so folio fault occurs and information technology replaces 1 which is the least recently used page.
When 1 comes, it is not available in memory so page error occurs and it replaces 2.
When iii,ane comes, it is bachelor in the retentivity, i.eastward., Page Hit, so no replacement occurs.
When 6 comes, it is not bachelor in retention so page mistake occurs and it replaces iv.
When iii comes, it is available in the memory, i.e., Folio Hit, so no replacement occurs.
When 2 comes, it is not available in retention so folio fault occurs and information technology replaces v.
When 3 comes, it is available in the retentivity, i.e., Page Hit, so no replacement occurs.
Page Fault ratio = 8/12
Advantages
- Efficient.
- Doesn't suffer from Belady'south Anomaly.
Disadvantages
- Complex Implementation.
- Expensive.
- Requires hardware back up.
Optimal Page Replacement
Optimal Folio Replacement algorithm is the best page replacement algorithm as it gives the least number of page faults. Information technology is also known as OPT, clairvoyant replacement algorithm, or Belady's optimal folio replacement policy.
In this algorithm, pages are replaced which would not be used for the longest duration of time in the future, i.east., the pages in the memory which are going to exist referred farthest in the future are replaced.
This algorithm was introduced long back and is hard to implement because information technology requires future knowledge of the programme behaviour. However, it is possible to implement optimal page replacement on the second run by using the folio reference information collected on the outset run.
For Instance
Total Page Fault = 6
Initially, all iv slots are empty, so when 1, 2, 3, 4 came they are allocated to the empty slots in club of their arrival. This is page fault every bit one, 2, three, 4 are non available in memory.
When v comes, information technology is not available in retention and so page fault occurs and it replaces iv which is going to be used farthest in the hereafter amidst one, ii, 3, 4.
When 1,iii,i comes, they are available in the memory, i.e., Page Hit, so no replacement occurs.
When 6 comes, it is not bachelor in memory so page fault occurs and it replaces ane.
When 3, 2, 3 comes, it is bachelor in the memory, i.e., Folio Hit, and then no replacement occurs.
Folio Error ratio = 6/12
Advantages
- Easy to Implement.
- Simple information structures are used.
- Highly efficient.
Disadvantages
- Requires time to come knowledge of the plan.
- Time-consuming.
So, these are some of the page replacement algorithms that are used in paging. Hope y'all learned something new today.
Continue Learning :)
Team AfterAcademy!
Source: https://afteracademy.com/blog/what-are-the-page-replacement-algorithms
Post a Comment for "what other block replacement technique can be used and is proved to be the ideal"