 assistant professor, department of electronic engineering, WD Solopor. In this video lecture, we are going to discuss about the page replacement algorithm FIFO that is first in and first out. At the end of this video, you will be able to describe the need of the page replacement. You are able to describe the working principle of FIFO algorithm and you are able to make comments on the performance of FIFO algorithm. Let us see some important terms regarding the paging and the page replacements here. What is paging? Now paging is a memory management scheme by which a computer stores and retrieves data from secondary storage for use in the main memory. Because we know here always the CPU expects the required page into the main memory. So we are going to transfer the page from the secondary memory back in the main memory. Now in the need of paging, naturally whenever the CPU is executing some process here and suppose we do not find any required page into the main memory, then the operating system signals a page fault and it indicates that there is no required page is available into the main memory. And hence we are going to transfer the required page from the secondary memory back into the main memory. So in this case we require the paging to get the required data or a page into the main memory. Now hence there are some terms are coming frequently one is called the swapping in. Suppose we get some page fault that is we need to transfer a page from secondary memory back into the main memory. So this process of transferring a page from secondary memory to the main memory is called as a swapping in. Also this one more term is coming here is called the swapping out. Suppose if we get a page fault and suppose there is no empty space is available in the main memory. So in this case we are not able to transfer any page from the secondary memory back in the main memory. So that we have to create some space in the main memory. That is we are going to take away some page from main memory and so that we are going to create some space in the main memory. So taking out a page from main memory is normally called as a swap out. Now we also come across a term called as a page sheet. Whenever the required page is found in the main memory it is said that there is a page sheet is occurred. That is the CPU is going to execute all the process with the help of data on the main memory. Page fault is one more term. So whenever data is not available on the main memory it is said that a page fault is occurred. Now in this case we need to create the page transfer from the secondary memory back into the main memory. Now that one parameter or maybe two parameters here they will denote the performance of this algorithm. It is normally called as a page hit ratio. This ratio is a ratio of the total number of page hits we encounter to some of the total page faults and the total page hits during the memory access. Similarly we also can find out one more ratio can be called as the page fault ratio. Now these two are the performance measurement parameter for this page replacement algorithms. Let us see as I said here suppose we do not have any space on the main memory to store a required page coming from the secondary memory on the memory. So in that case we need to go for some page replacement strategy. The number of possible ways are available here. The one of the ways is taken to be the first in and the first out policy. So it is taken as the FIFO page replacement algorithm. So it works on this following basis here or the points I can say. If the page required by the process is not available on the main memory then we are going to have some sort of alarm signal called as the page fault here. So that we are going to so in this case the CPU is going to hold instruction which is creating the page fault here and the control is transferred to the next process here. So that we are going to make a space for the new incoming page from the secondary memory. Now suppose there is no space is available in the main memory. So where to store the new incoming page from the secondary memory. Now in the first in first out policy we are going to store the new incoming page from the secondary memory in that slot in which we are holding the oldest page in the main memory. That is the page which was brought initially in the main memory was deleted and in that space we are going to accommodate the new incoming page from the secondary memory. Now in that after that transferring this new page in the secondary memory so in the main memory we are going to update the page table and we are going to restart the execution of the halted instruction. Now in this case let us understand the working of FIFO algorithm. Let us take my example. Now in this case we have got example as we are having some page references are given here. It means that the process under execution require these pages in the given sequence to execute the program which is under execution here. So in the example we say that there are 4 page frames are available in the system. That is the CPU is allocating only 4 pages or the 4 frames in the main memory. So we have to manage this memory here so that we can execute this entire process properly in the given sequence. Friends this diagram shows you a small table. On the top I am writing here the page references as mentioned in the example. The example also mentions the page frames are available having only 4 as a number here. At the bottom I am writing some message such as the page hit or the page fault here. Pages stand for H and we denote page fault by a letter F here. Now when we start this execution initially all the frames in the main memory are empty. So that we are going to transfer the required pages in those empty slots here. Let us see suppose example my process starts to execute here. So initially I require a page 0. As we know initially all the frames are empty. So obviously I will not get data in the main memory here. So I am going to create a page fault here. At this point we need to go for the demand paging that is we are going to transfer the page 0 which is maybe from the secondary memory into the main memory here. So after that I am going to transfer this page 0 in the empty frame which is in the main memory. Secondly the process is not tried to execute the second phase. So he require now second page to be accessed here from the main memory. But we know here this page is not available. So again I am going to create a page fault and again we are going to transfer this page number 2 into the empty slot in the main memory here. So our memory already holding this page 0 in the previous transfer and I am going to transfer the second page now into the second frame slot in the main memory here. Now again process require the third frame as 1 or the third page as 1 which is again not available. So we are going to create a page fault here and again we are going to transfer this page number 1 into the empty slot in the main memory here. So again we are going to have this kind of allocation as shown in the figure. Means I am going to transfer the page number 1 in the third slot in the third column. Similarly after that we require frame number 6 or the page number 6 which is not available in the main memory. So again we are getting this page fault here. So again we are going to transfer this page number 6 into the empty slot in the main memory. Now friends in the next phase of execution I require the page number 4 and here we don't have page number 4 in the memory so that we had to make some demand paging. So I need to transfer the page number 4 into the main memory but already the memory is filled by all the possible frames in the previous cycle of execution here. So we had to create a new empty space. Now here the FIFO algorithm says that you are going to make the empty slot by deleting the oldest frame that we brought in the FIFO here that is sorry in the frame or main memory I can see here. So here we have brought the page number 4 in that slot here. So I am going to transfer the new page here from the secondary memory into the main memory at the place of the zero frame. So friends I am going to have this transfer is shown like this here and I am going to keep all these other frames as same as this one. Similarly when I go for the next phase of execution here I require the zero page here which is again not in the given main memory here. So again we are going to create a frame page fault here that is now shown by this FIFO. Now I am going to make the empty space at the frame number 2 which was oldest now at the current instant. So I am going to transfer this page zero at the second slot and I am going to keep all remaining frames as it is here. Now in this case the next I require the page number 1. Friends currently my main memory is containing page number 1 already in the main memory. So we do not require any kind of page transfer here. So I am going to keep these distribution as same as this one here it is normally called as a page sheet. So we denote this by h later here and we are going to have the same distribution of the frames in the main memory. Similarly the next I require zero frame here so again we get a page sheet. So again the memory is remaining very much same in this one. So in this way we are going to have this page transferred from the secondary memory back into the main memory here. Friends we just carry on the same iteration for the next. So again we create the page fault here. Now we are going to create a space for the page number 3 in the given column as shown in the figure and we are going to keep this remaining frames as it is here. And this process is remain here in the system until we are going to switch all the required pages into the main memory. So friends this entire chart shows you the required process to bring the required pages from secondary memory back in the main memory using this principle called as a FIFO. And in this case you see that we are occurring total number of page faults equal to 9 and we are having 3 page hits in the entire process. As I said here this ratio is called as a page heat ratio is a ratio of the total number of page hits upon sum of total page hits and the total page faults here. So this ratio is comes to be 0.25 you also can express this term in terms of the page fault ratio it comes to be 0.75. Friends in the FIFO we have got some issues to be addressed here. Now in a year normally the most useful page is kept in the memory for longer time isn't it and we know in the FIFO principle we always replace the oldest frame in the given system to create a space for new frame for the process execution here. So in this case it is seen that the FIFO doesn't consider the page usage at all here means it is possible that the most required page had to be deleted by the FIFO principle so as to make a space for the new incoming frame. So friend this is the principle called as a FIFO I hope we understand the working of FIFO the issues of FIFO you also understand the example we carried in this slide show here and these are my references and thank you thank you friends thank you very much.