Virtual Memory


  • Allow applications larger than physical memory to execute.
  • Run partially loaded programs – Entire program need not to be in memory all the time.
  • Multiprogramming: Many programs simultaneously reside in memory.
  • Allow re-locatable programs – anywhere, anytime
  • Application Portability:
  • Applications should not have to manage memory resources
  • Write machine independent code – program should not depend on memory architecture.
  • Permit sharing of memory segments or regions. 
  • For example, read-only code segments should be shared between program instances.
  •   When a page fault occurs, the Operating System: 
  • moves the current process to the blocked/waiting state (since it must wait for a page to be made resident).
  • finds an empty frame or, if necessary, makes a frame empty in main memory by swapping out a page in the main memory.
    determines the location of the requested page on the paging device.
    schedules a disk read operation to load the page into the selected main memory frame (via a “pagein”)
    later handles page fetch completion (which is recognized via an I/O completion interrupt) and then moves the blocked process back to the ready state.
     Check an internal table for this process, to determine whether the reference was a valid or it was an invalid memory access.
    If the reference was invalid, terminate the process. If it was valid, but page have not yet brought in, page in the latter.
    Find a free frame.
    Schedule a disk operation to read the desired page into the newly allocated frame.
    When the disk read is complete, modify the internal table kept with the process and the page table to indicate that the page is now in memory.
    Restart the instruction that was interrupted by the illegal address trap. The process can now access the page as though it had always been in memory. Therefore, the operating system reads the desired page into memory and restarts the process as though the page had always been in memory.

Comments