On 2010 Nov 9, at 2:22 AM, Johnny Billquist wrote:
- 1. User addresses map directly to physical addresses.
User address 0 is physical address 0. The user address space is
obviously limited to 1MB or less of memory and the user will be aware
of such
if an attempt to address beyond that is made.
Yes. And if you have several processes, they are all aware of each
others memory space, and care must be taken that they do not wander
outside their own confinements and clobber things in the system
(including the OS). Programs must be written to be memory aware, and
either PIC, or else linked to run at a specific address, since there
is no virtual memory.
- 2. We add an MMU to map addresses.
Multiple user address spaces may exist and can be mapped to
different
areas in physical memory. User address 0 may or may not ref
physical address 0.
A user is still aware of a limited address space dictated by the
1MB of
physical memory. The total of the user address spaces cannot
exceed 1MB.
Indeed. And it can be an arbitrary lower limit than 1 MB as well. And
at this point, programs can be written to not be memory aware. All
programs can be written without consideration to what addresses they
use. All can be linked to start at the same address, and run in
parallel. They are not aware of, nor do they see other programs memory
space. They can be PIC, or position dependent. They can clobber all
their memory, and the system itself is not affected.
- 3. We add swapping-to-disk.
The system as a whole is no longer limited to 1MB of memory,
there may be
multiple user address spaces totalling more than 1MB of memory.
Each user
however, is still limited to a max of 1MB of address space, i.e.
each user
is still aware of the limited physical memory.
Right. Adding swap does nothing more than grow the capacity of the
system total. For a single process, it is invisible.
- 4. We add address-faulting, demand-paging
- whatever one wants
to call it.
The user address space is no longer limited by physical memory.
The user can
hit any address in their 32-bit space and (magically) find a
valid memory
location there. More physical memory can be added (or removed)
'underneath'
the user(s) without their awareness.
Except, or course, the OS can still limit you to use less than 1 MB.
Adding paging does nothing for the individual program as such. It is
totally invisible. You might argue that it gives you the possibility
to use more memory than physically available, and that is true, but
that is at the discretion of the OS. To get more memory, you will need
to call the OS to request more memory, and the OS can allow or deny
this request. Same as in #2 above.
If we are discussing on the basis that the OS (which I will take to
mean "system") can limit you to whatever it feels like, then it can
limit you to no address-mapping at all, no virtual addresses, no
virtual memory, and there is nothing to discuss.
By the
nomenclature I grew up with or suffer under, the term "virtual
memory" only applies in scenario 4, although "virtual addresses" could
be said to have been introduced in scenario 2.
The difference between 2 and 4 is only that the OS *can* allow you to
use more memory in scenario 4, not that it necessarily will allow it.
What the system *can* allow you to do, what abilities it has the
*potential* to provide, are exactly what distinguishes the scenarios
and systems. That the system *can* allow you to use more memory in
scenario 4 - transparently access more memory in a single linear
address space than there is physical RAM - is exactly the point, and
what distinguishes it from the other scenarios.
Or, scenario 4
was my understanding of the *commonly-agreed-upon
application* of the phrase "virtual memory", although I would not
argue
that in a very general sense it may be applied to scenario 2 or 3.
The difference between 2, 3 and 4 is actually extremely vague. The
only actual difference is that the OS *can* allow you to use more
memory. But let's say that the OS will not. Does that suddenly mean
that you don't have virtual memory, even though it is indeed using
page demand loading and all that fancy stuff?
The differences between scenarios 2 & 3 & 4 are not vague, there are
fundamental differences between them - whatever terms one chooses to
apply to denote them. Introducing arbitrary minimum limits imposed at
the whim of the OS is a straw argument.
And this also totally ignores the scenario that exists
under the
PDP-11, and which started this thread. What if you have more physical
memory than can be addressed by virtual memory?
That's a whole different ballgame, and is not covered by any of your
scenarios...
IIRC it began with the contributions or abilities of the VAX. I think
somebody may have suggested that the PDP-11 could do all those things.
The discussion then threaded off into the use or meaning of the phrase
"virtual memory". It seems there are multiple definitions in use, some
may be more common than others, none are "correct" or "incorrect".
The ad-absurdum extension of this debate is that these are all
universal machines, they are all capable of emulating the others, all
capable of whatever the others are, there is nothing to distinguish
them, (and they are all capable of nothing if the OS wishes to limit
one to such).
All in good spirit. :-)
OK.