 Hello friends. Myself Rohit Kumar Vakhtarikar, working as an assistant professor in computer science and engineering department. Today, we are going to discuss on the demand paging in operating system. Learning outcome. At the end of this session, students will be able to describe the page faults and students will be able to identify the necessity of demand paging. So, let's start for the demand paging. In this demand paging, we need to understand the virtual memory and then we will go for the demand paging. So, whenever we will open any application at that time, that particular application is going to be loaded in our main memory. So, let's consider this is our one application which is going to take some data or take some memory in our RAM. So, now while executing this particular application, whenever any application we are going to run on our system, that application is considered as one process. So, now let's say we will have one RAM. So, the amount of memory is let's say we will have the 1 GB of the RAM in our system. So, now whenever we are going to double click or open that application, we need to place that application into the memory. So, let's say we will have one application and that application is needed 2 GB of memory. So, now while performing these operations, it means while running that particular application, that particular application is needed as 2 GB of RAM or memory that is nothing but our logical address. So, now when that particular application is running, we need to place that application into our RAM and here we will have that RAM with a 1 GB of memory. So, now while performing this operation, storing this 2 GB of RAM, 2 GB of application into the 1 GB of RAM is not possible. So, now this is nothing but our physical memory. So, RAM is nothing but our physical memory. So, now while performing this operation, then what the option will get then? So, now on the disk we will have this application. So, basically let's consider we will have this disk. So, now in this disk, we are going to execute that particular applications. We have stored that application here. So, now whenever we will install any operating system, so at that time we need to keep some space free in C drive, D drive anywhere where you have installed that particular operating system. Why? Because our operating system is going to use the virtual memory. So, now what is mean by virtual memory then? Operating system is going to use virtual memory. Then what is mean by virtual memory then? So, the virtual memory is nothing but the space on disk which acts as a RAM, fine. So, means what? If that particular application is not able to fit into this particular physical memory, so at that time we need to use this particular virtual memory, fine. We need to use that one. So, now how we are going to use that one then? So, here that particular application need to use let's say on this disk, let's say this is our disk. So, on this disk we will have the virtual memory, so this is our virtual memory. Let's consider this our virtual memory. So, now on this virtual memory we are going to load that application. So, now here we are going to load that particular application, this is our application and this application we are going to load into that virtual memory. So, now how in the which form we are going to load that one? So, to perform that what we need to do? We need to divide the application, divide application into pages, right. So, now that particular application has been divided into the pages and here we have loaded that particular application in the form of pages, right. So, now whenever particular application is needed, let's say now we got the what is the use of that particular virtual memory, right. So, that virtual memory is nothing but the space on disk which acts as a RAM, fine. So, now currently here we will have only one GB of RAM, right. So, now executing that much of application, 2GB application is not possible, right. We can't load that 2GB of application into the RAM. So, that's why we are going to use the virtual memory, right. So, now how we are going to utilize then that application is going to be divided into the pages, right. The application has divided into the pages. So, now we are going to use those pages. Now these are the pages, right. So, these pages are going to be loaded there. So, now see, now we will have these pages here. So, how we are going to load this? Then what we will do? Now this memory or RAM has been again divided into some blocks, right, fine. So, those blocks are nothing but our friends. So, these are the blocks and we can call it those are nothing but the friends, fine. So, now we need to load these pages into the frame on demand, right. So, basically that is nothing but our virtual memory we have seen. So, now let's discuss about the demand paging, right. So, let's discuss about this demand paging. So, now what happens in a demand paging? So, now in demand paging what we need to do? That demand paging is nothing but the combination of paging and swapping, fine. It's a combination of paging and and swapping, right. So, how we are going to do that then, fine. So, let's say consider here again paging is a concept we got it that page is nothing but the application is divided into the pages. So, now what is meant by the swapping, right. So, now here let's say we will have our disk, fine. This is our disk. So, now in this disk we will have the pages, fine, we will have small small pages, right. Those applications are divided into the pages, fine. So, let's say these are our pages. So, now while performing this, now here we will have a RAM, fine. This is our RAM. So, now this RAM has been divided into the frames, right. So, now while performing these operations, right, while performing these applications, right. So, say in this particular RAM currently one application is running. So, now that application is running and the some part of that application is stored in the disk, right. Because we are going to use the virtual memory. So, at that time this particular application is demanding for some pages from the disk, right. Let's say he wants to access this page, right. So, now at that time we need to perform swap in and swap out operations, all right. Swap in and swap out two operations, right. Why? Because the some part of the memory is in the disk and some part of the memory is in the RAM. So, on demand we are going to load the pages into the RAM by performing swap in and swap out operations. Swap in means what? We are going to take that particular page from the disk into our main memory and after completion of that task then we are going to release that particular frame, right. So, if you see this diagram what we are getting is these are nothing but our frames, right. Means what? We are going to store the pages into the frames, right and these are nothing but our pages, right. So, these are nothing but our pages. So, on demand we are going to perform this operation. So, that's called the demand paging, fine. So, we have seen both of the things. So, let's think and write. What if the number of page faults are so high and CPU remains busy in just reading the pages from the secondary memory? What happened? Just think on this, ok. Let's see. Then the effective access time will be taken by the CPU and read one word from the secondary memory and it will be so high that concept is going to be called thrashing, right. So, thrashing is going to be happen if you look into that particular question, ok. So, now what is mean by effective access time? So, basically we are going to calculate the first page fault. Page fault means what? Looking for some pages, that page is currently not available in our frame. That is nothing but the page fault. So, now here we need to find out the again restarting service. So, if page fault is happen then we need to restart it, right and we need to perform the memory access time also. So, now here we got our formula. Effective access time is equals to page fault multiplied by service time plus 1 minus r page fault into memory access time, ok. So, these are the reference. We got this concept from the Galvin operating system concepts from the 6th editions. Thank you.