Storage Management

•   Demand Paging




                                    1
Recap

In the last class, you have learnt:

Virtual Memory

• Advantages of virtual memory




                                      2
HOME     PREVIOUS TOPIC NEXT
PREVIOUS QUESTION PAPERS FOR OS
CPP TUTORIALS




                                  3
Objective


 On completion of this class you will be able to
 know
• Demand Paging




                                                   4
Demand Paging

• Demand paging system is similar to a paging
  system with swapping
• A lazy swapper swaps a page into memory only
  when it is needed
• A process is a sequence of pages rather than
  one large contiguous address space
• In demand paging instead of swapper the term
  pager is used
                                                 5
Demand Paging

• Bring a page into memory only when it is needed
  – Less I/O needed
  – Less memory needed
  – Faster response
  – More users


• Page is needed ⇒ reference to it
  – invalid reference ⇒ abort
  – not-in-memory ⇒ bring to memory
                                                6
Demand Paging
•When     a page is referenced, and that page isn’t in memory,
•   then get the page from disk and re-execute the statement
•Here’s    migration between memory and disk


          Program A



          Program B




                      Physical            Disk
                      Memory
                                 Fig 1
                                                                 7
Transfer of a Paged Memory to Contiguous
                Disk Space




                  Fig 2
                                       8
Valid-Invalid Bit
•   With each page table entry a valid–invalid bit is associated
    (1 ⇒ in-memory, 0 ⇒ not-in-memory)
•   Initially valid–invalid but is set to 0 on all entries
•   Example of a page table snapshot               Page table

•   During address translation, if valid–          Frame #      valid-invalid bit
                                                                1
    invalid bit in page table entry is                          1
    0 ⇒ page fault                                              1
                                                                1
                                                                0
                                                      

                                                                0
                                                                0
                                                      Fig 3
                                                                              9
Page Table When Some Pages Are Not in
            Main Memory




                 Fig 4
                                    10
Demand Paging
Steps in handling a page fault
•   The process has touched a page not currently in
    memory
•   Check an internal table for the target process to
    determine if the reference was valid ( do this in
    hardware )
•   If it was valid, but page isn't resident, then try to get it
    from secondary storage
•   Find a free frame; a page of physical memory not
    currently in use (May need to free up a page )

                                                              11
Demand Paging
• Schedule a disk operation to read the desired page into

  the newly allocated frame

• When memory is filled, modify the page table to show

  the page is now resident

• Restart the instruction that failed

• Do these steps using fig 5 which you can see on the next

  slide



                                                        12
Demand Paging




     Fig 5
                13
Frequently Asked Questions

• What is demand paging ?

• What is page fault ?




                                      14
Summary


 In this class, you have learnt

• Demand paging is used to get a page into

  memory only when it is needed




                                             15
Quiz
1. Demand paging system is similar to a paging
 system with
 a) Segmentation
 b) Swapping
 c) None

2. In demand paging instead of swapper the term
 __________is used
 a) Page offset
 b) Hole
 c) Pager
 d) None
                                                  16
Other subject materials

•   Web designing
•   Micro processors
•   C++ tutorials
•   java

home

40 demand paging

  • 1.
    Storage Management • Demand Paging 1
  • 2.
    Recap In the lastclass, you have learnt: Virtual Memory • Advantages of virtual memory 2
  • 3.
    HOME PREVIOUS TOPIC NEXT PREVIOUS QUESTION PAPERS FOR OS CPP TUTORIALS 3
  • 4.
    Objective On completionof this class you will be able to know • Demand Paging 4
  • 5.
    Demand Paging • Demandpaging system is similar to a paging system with swapping • A lazy swapper swaps a page into memory only when it is needed • A process is a sequence of pages rather than one large contiguous address space • In demand paging instead of swapper the term pager is used 5
  • 6.
    Demand Paging • Bringa page into memory only when it is needed – Less I/O needed – Less memory needed – Faster response – More users • Page is needed ⇒ reference to it – invalid reference ⇒ abort – not-in-memory ⇒ bring to memory 6
  • 7.
    Demand Paging •When a page is referenced, and that page isn’t in memory, • then get the page from disk and re-execute the statement •Here’s migration between memory and disk Program A Program B Physical Disk Memory Fig 1 7
  • 8.
    Transfer of aPaged Memory to Contiguous Disk Space Fig 2 8
  • 9.
    Valid-Invalid Bit • With each page table entry a valid–invalid bit is associated (1 ⇒ in-memory, 0 ⇒ not-in-memory) • Initially valid–invalid but is set to 0 on all entries • Example of a page table snapshot Page table • During address translation, if valid– Frame # valid-invalid bit 1 invalid bit in page table entry is 1 0 ⇒ page fault 1 1 0  0 0 Fig 3 9
  • 10.
    Page Table WhenSome Pages Are Not in Main Memory Fig 4 10
  • 11.
    Demand Paging Steps inhandling a page fault • The process has touched a page not currently in memory • Check an internal table for the target process to determine if the reference was valid ( do this in hardware ) • If it was valid, but page isn't resident, then try to get it from secondary storage • Find a free frame; a page of physical memory not currently in use (May need to free up a page ) 11
  • 12.
    Demand Paging • Schedulea disk operation to read the desired page into the newly allocated frame • When memory is filled, modify the page table to show the page is now resident • Restart the instruction that failed • Do these steps using fig 5 which you can see on the next slide 12
  • 13.
  • 14.
    Frequently Asked Questions •What is demand paging ? • What is page fault ? 14
  • 15.
    Summary In thisclass, you have learnt • Demand paging is used to get a page into memory only when it is needed 15
  • 16.
    Quiz 1. Demand pagingsystem is similar to a paging system with a) Segmentation b) Swapping c) None 2. In demand paging instead of swapper the term __________is used a) Page offset b) Hole c) Pager d) None 16
  • 17.
    Other subject materials • Web designing • Micro processors • C++ tutorials • java home