2
4.2kviews
Explain Demand Paging.
1 Answer
3
358views

Solution:

What is Demand Paging?

  • Demand paging, is a technique used in virtual memory systems where the pages are brought in the main memory only when required or demanded by the CPU.

  • It's defined as a process in which the pages are loaded into the memoryor on-demand.

  • Let us take an example, suppose there is a 1000 MB application and it may need as little as 200MB pages to be swapped, so in this case, there is no need to swap all pages at once.

How can work demand paging?

  • If there is a page that CPU wants to refer, but currently in the Main Memory.

enter image description here

  • That page is not available, then in this situation, an interrupt is generated by the CPU, which indicates that there is memory access fault.

  • The operating system will put the process in a blocked state. That will search that page in the backing store or secondary memory. To proceed the execution, the operating system takes the page which is needed into the Main Memory.

  • Next, the operating system will update the page table entry accordingly.

  • The logical address space to the physical address space, the needed page will be carried.

  • Hence a page fault occurs these steps are followed by the operating system and the required page is brought into memory.

Effective Memory Access time in Demand Paging:

  • p(page fault) while executing any process then the effective memory access time is calculated as follows:

Effective Memory Access time = (p)(s) + (1-p)(m)

where, P =  page fault rate.

S = page fault service time.

M = main memory access time.

Advantages of Demand Paging:

  • Demand paging avoids External Fragmentation.

  • By using demand paging, we can run programs that are larger than physical memory.

  • It increases the degree of multiprogramming as many processes can be present in the main memory at the same time.

  • This process is not constrained by the size of physical memory.

  • Memory can be used more efficiently.

Disadvantages of Demand paging:

  • Memory access time in demand paging is longer.

  • In demand paging, there may be a chance of internal fragmentation.

Please log in to add an answer.