12-09-2013, 12:29 PM
10 Virtual Memory
Virtual Memory.ppt (Size: 669 KB / Downloads: 18)
Background
all memory management algorithms outlined so far require that all of the processes are kept in physical memory
contiguous allocation
paging
segmentation
overlay is an exception, but it requires special effort of the programmer
explicit memory allocation and free operations in an application program
Virtual Memory
virtual memory – separation of user logical memory from physical memory, allows an extremely large virtual memory to be provided to programmers when only a smaller physical memory is available
only part of the program needs to be in memory for execution
logical address space can therefore be much larger than physical address space
allows address spaces to be shared by several processes
allows for more efficient process creation
common implementation
virtual memory can be implemented via:
demand paging
several system provide a paged segmentation scheme, i.e., the user view is segmentation, but the OS can implement this view with demand paging
demand segmentation
Page Fault
if all reference attempts to access pages already in memory, the process will run exactly as though we bring in all pages
if there is ever a reference to a page not in memory, first reference will trap to OS page fault
Copy-on-Write
Copy-on-Write allows both parent and child processes to initially share the same pages in memory
if either process modifies a shared page, only then is the page copied
Unix, Linux: fork( ) followed by exec( )
copy-on-write allows more efficient process creation as only modified pages are copied
currently used by Windows 2000, Linux, and Solaris 2
Memory-Mapped Files
Memory-mapped file I/O allows file I/O to be treated as routine memory access by mapping a disk block to a page in memory.
A file is initially read using demand paging. A page-sized portion of the file is read from the file system into a physical page. Subsequent reads/writes to/from the file are treated as ordinary memory accesses.
Simplifies file access by treating file I/O through memory rather than read( ) write( ) system calls.
Also allows several processes to map the same file allowing the pages in memory to be shared.
Reference String
many algorithms, how to evaluate?
lowest page-fault rate
we must evaluate an algorithm by running it on a particular string of memory references
(page) reference string: page numbers only, with adjacent duplications eliminated