Demand Paging in Operating System

Demand Paging in Operating System img

Demand Paging in Operating System

The basic purpose of the OS is reduce load on the system and become more efficient. Consider that a process enters the system i.e. swapped in. Every process as we discussed in the virtual memory post here has a lot of pages.  It might not be suitable and efficient to swap or load all the pages for the process at once. As the program may only need only a certain pages for the application to run.  

The basic purpose of the OS is reduce load on the system and become more efficient. Consider that a process enters the system i.e. swapped in. Every process as we discussed in the virtual memory post here has a lot of pages. 

It might not be suitable and efficient to swap or load all the pages for the process at once. As the program may only need only a certain pages for the application to run.

  • Infact, in cases a 1GB application may need as little as 20MB pages to be swapped so there is no need to swap all at once.

Demand paging is the process that solves, this by only swapping pages on Demand. This is also known as lazy swapper.

Demand Paging in OS

How Demand Paging Works?

The main components involved in the process are –

  • CPU
  • Main Memory
  • Interrupt
  • Secondary Memory
  • Logical Address space
  • Physical Address space
  • Page Table
  • Operating System
  1. A request may be made to the CPU for a page that may not be available in the main/primary memory in active state. Thus, it has to generate an interrupt.
  2. This is when the Operating system moves the process to a blocked state as an interrupt has occurred.
  3. The Operating system then searches the given page in the Logical address space
  4. Finally with the help of page replacement algorithms, replacements are made in the physical address space. Simultaneously, page tables are updated.
  5. CPU is informed about the update and asked to go ahead with the execution and process gets back into the ready state.

Page Fault Service Time

Whenever a page fault occurs, the CPU takes considerable amount of time to perform the above mentioned steps. This time taken by the CPU is called as page fault service time.

  • Access time for Main memory : m
  • Service time for Page fault: s
  • Rate for Page fault Page fault rate is : p
  • Effective memory access time = (p*s) + (1-p)*m
    • This formula is important for both placements and gate.

Page Fault

Read more about page fault here on this page here.

Thrashing

Read more about thrashing here on this page here.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription