[comp.sys.mac.system] Virtual Memory

bitting-douglas@cs.yale.edu (Douglas Bitting) (05/30/91)

Virtual Memory, like many other things in an OS, can be implemented in many
ways.  It all boils down to the design decision made by the OS programmers.
Basically, the trade off in implementing VM as Apple has is speed over disk
space.  When the entire Virtual Memory space is mapped to a disk, the operating
system is assured that any page in memory that is clean (ie, unchanged since
read in from the disk) is on the disk somewhere.  This means that when said
page is to be swapped out, it does not have to be written to the disk first.
This results in an *immense* speedup.  How immense?  RAM accesses are on the
order of nanoseconds... disk accesses on the order of milliseconds (a factor of
10^6 difference, I believe ... someone correct me if that is wrong).  So, if
you can eliminate 1 disk access per page swap, you are saving (assume disk
access time to be 15ms and RAM access time to be 80ns) 14.999992 ms ... this is
a difference you will notice in memory accesses.

Anyway, this is just one design consideration to be made when it comes to
Virtual Memory.  For further reference, I would recommend _Operating Systems_
by Silbershatz and some others (I don't remember, I left my book at school).
It is a text book, but it is a very informative and well written one.

--Doug

-- 
Doug Bitting             | "And we know that in all things God works
PO Box 3043 Yale Station |  for the good of those who love him..."
New Haven, CT 06520      |                       --Romans 8:28
bitting@cs.yale.edu      +------------------------------------------

erics@sco.COM (eric smith) (06/02/91)

bitting-douglas@cs.yale.edu (Douglas Bitting) writes:

>Virtual Memory, like many other things in an OS, can be implemented in many
>ways.  It all boils down to the design decision made by the OS programmers.
>Basically, the trade off in implementing VM as Apple has is speed over disk
>space.  When the entire Virtual Memory space is mapped to a disk, the operating
>system is assured that any page in memory that is clean (ie, unchanged since
>read in from the disk) is on the disk somewhere.  This means that when said
>page is to be swapped out, it does not have to be written to the disk first.
>This results in an *immense* speedup.

Ah, but pages do have to be swapped out at some point if the data they
contain has changed. I"m not running System 7.0 yet (soon though, I hope),
so I haven't observed how Apple has implemented VM, but I assume they swap
pages that have changed on some time interval and certainly when the page
is swapped out. While having the entire contents of VM on disk may save
some disk IO (because not every page's data changes), the savings will vary
greatly depending on the type of applications running. I suspect that the
main reason to have the entire VM on disk is to greatly simplify the page
management algorithm and eliminate fragmentation of memory contents on disk.

--------------------------------------------------------------------------
| Eric Steven Smith      \       /    How did the programmer die in      |
| Usenet: erics@sco.com   \     /              the shower?               |
|         erics@netcom.com \   /       By reading the instructions:      |
| CompuServe: 70262,3610    \ /           Lather. Rinse. Repeat.         |
--------------------------------------------------------------------------