 Department of Electronics from Valtry Institute, Solapur today in this lecture I am going to discuss with you a very important concept of paging in the operating system. Now, in this video lecture we are having these objectives that is at the end of this video you are able to describe the concept of paging then we are able to describe the various benefits and drawbacks of the paging. Now, in this the goals are we will understand what is the memory management then what is the meaning of external fragmentation then the paging mechanism and the paging table concept. As we all know here during process execution we use the memory. Now normally the program is stored in the logical memory or I can say hard disk or also called as a secondary memory that is prefaced by the operating system and is brought into the main memory and the CPU is going to access the data from the main memory for execution. But whenever the CPU start execution it generates the logical address and this logical address always points the data inside the physical memory or in the secondary memory I can say. So, we are going to preface the data from this secondary memory and is brought into the main memory. Now MMU is nothing but the memory management unit it help us to bring the data from the secondary memory to the main memory by converting the logical address into the physical address. This one more thing is to be understood is that the virtual address is always in the secondary memory it always start with the base as zero and the MMU is going to bring the data from the secondary memory back into the main memory. The figure shows you that concept here. The MMU is going to address the memory as well as the IO devices and the address which we used to point out these two devices is normally called physical address. As I said here whenever the CPU is going to select a process for execution it generates a virtual address. Now this address is always pointing towards the secondary memory because CPU always get data for execution from the main memory which mean that we have to bring the data from secondary memory into the main memory in the advance it is normally called as a prefetching. So MMU is going to convert the data that is of virtual address type into the physical address which is pointing the main memory that is normally a case of RAM in our case. Now what is the paging here? The paging is a memory management scheme by which the computer stores and retrieves data from secondary memory into the main memory. So paging naturally in the paging we normally divide the secondary memory into equal slots here that is we are going to deal the secondary memory in parts it is normally called the partition. The two types of partitions the first is called equal sized partition and second is the unequal sized partition but normally we use the fixed partition or fixed sized partition in the paging scheme. So we divide this entire secondary memory into small blocks. Now each block is normally called as a page or I can say here I will divide this entire secondary memory in different pages. Now the program that we stored in the secondary memory that is now covering number of pages in the given secondary memory. Example a program can cover 15 pages in the given secondary memory. Similarly the memory manager divides the physical memory that is the RAM into again equal sized pieces that is called the frame. Normally the size of frame is always equal to the size of the page. But remember that the size of physical memory or I can say the size of main memory is always less than the size of secondary memory which means that we never going to bring all the contents in the secondary memory into the main memory or I can say reversely only interested part from the secondary memory is brought into the main memory. Now this diagram shows you that concept here I said that the secondary memory we are having one program so example program 1 it is covering page number 0 1 2 and so on. Now we are trying to preface data so this MMV is come in the picture he will convert different addresses in different required forms here so that we can bring the data on page number 0, page number 1, page number 2 into the physical memory. Now in this diagram the logical address space the secondary memory is having a program that covering that covers page number 0 1 and 2 whereas in the physical memory in the RAM it has got different frames numbered as frame 0 1 2 3 and so on. Now in the physical memory the frame number 1 is already occupied by some previous data in the computer or in the operating system so the frame 0 is open frame 2 is empty and frame 3 is empty here. Now this MMU is going to take atmosphere frame of where to put this page in the moment. Now as I said here the data is prefaced by the operating system so in diagram as I said here data is brought from the secondary memory and is brought into the physical memory. Now as you see here there are two options here this pages can be stored in the main memory either in the continuation it is normally called as a contagious memory allocation or these pages can be stored in different locations in the main memory this is normally called as a non-contagious memory allocation. So in this paging we can store all these pages that is from the secondary memory into the main memory either sequentially or in non-sequential fashion it is normally called contagious allocation or non-contagious allocation in the given main memory. For example I can take this example here suppose I got program 1 is suppose covering 15 pages in the secondary memory so as we all know these 15 pages are first brought in the main memory they are stored in different locations which are called as suppose the frame suppose currently the CPU is executing the is frame number one and suppose suddenly he wants the instruction which is present on the 14 number page now in this case the CPU is forced to read the page number one then he will go to page number two he will go to the page number four and after all this reading first 13 pages here he will get himself on the 14 number page here and where he is going to find the required instruction for execution now these kind of difficulties are reducing the speed of access here or reducing the speed of processing so to overcome this difficulty here the operating system manage one more table it is normally called as a page table now what is page table here page table is a table in which it has got two columns first he carries the page number and second he carries the frame number page table is a data structure it is not the hardware it is normally maintained in the main memory so the table shows that page number one is stored in the frame number one page number two is stored in now again just revise the problem here suppose example the CPU want to execute some instruction suppose on the page number two so it generates the logical address it normally has got two components here one is called the P2 that is the page number and second is the offset which is D in my case now this page number will load this or indicate the page number two so in this page table we are going to take a control on the page number two and we know in the table it shows that the page number two is stored in the frame number one which mean that the data of required quality or required quantity is found on the page frame number one so that I am going to convert this logical address as now not as P2 but as F1 and we know here I want the instruction which is at the deep location in the given page number two and we know here the size of page and the size of frame they are equal so I can find the required instruction in the frame number one at deep location and this collective information is going to point the main memory that points the page number two that is the frame number one and in which I am going to find out my required instruction now in this way we are going to find the paging here now you see that in this case the in this case the pages are stored in different locations so that there is no not a case of any external fragmentation case here secondly we take the help of the page table now page table is stored in the main memory is indicated by a register is normally called as a page table based register now what are the advantage of this paging here in the paging we can store the pages in non-conditious fashion in the main memory so we never get external fragmentation there then as the data is in the main memory the access time is always less and we are having the faster process execution here and now what are the drawbacks of this paging here as we know here before we start reading the frames data here we first refer the paging table here so that always kept in the main memory here so Cp has to first read the paging table here and then he will read the required frame which contains the required data which means that the Cp also read this main memory twice to execute a processor and hence the time required to execute a process is get increased here or the speed is get lower down here and secondly the internal fragmentation problem is not completely resolved here because some page may not be covering all the frame here so in which some of the space in the frame will remains empty here so this problem is not at all resolved here but is normally ignored here because that is not so much disturbing in the processing here now these are my references here friends i expect that you understand the concept of paging here thank you thank you much