Virtual Memory- Demand Paging

 

Demand paging introduces the concept of loading only a part of the program into memory for processing. When a process begins to run, pages are brought into memory only as they are needed.

 

It was the first widely used scheme that removed the restriction of having the entire job in memory from the beginning to the end of its processing. With demand paging, jobs are still divided into equally sized pages that initially reside in secondary storage. When the job begins to run, its pages are brought into memory only as they are needed.

 

Demand paging takes advantage of the fact that programs are written sequentially so

that while one section, or module, is being processed all of the other modules are idle.

 

Demand paging allows users to run processes with less main memory than would be required if the OP system was using any of the schemes described earlier. Demand paging can give the appearance of almost infinite amount of physical memory.

With a virtual memory system, the logical address space available to a program is totally independent of the amount of physical memory space. For instance a program may have a logical address space of 220 bytes and be capable of running in a system with only 216 bytes of physical memory.

 

Three tables used in demand paging:

 

Job Table

Page Map Table –part or all loaded into memory depending on size of virtual address space of process. For example in Vax architecture a process can have 232 =2 Gb of virtual address space. If each page was 29 =512 Bytes then there would need to be 222 entries in the page table per process –most systems store page tables in virtual memory rather than real memory.

 

Memory Map Table

 

Page Table

Three extra bits are required in the page table for demand paging.

· page table present in memory (P bit)

· whether the page has been modified or not ( M bit)

· if the page has been referenced recently ( R bit)