Thanks
hmm.. i just found the relevant textbook -- Operating Systems Concepts, 5th ed, (Silberschatz, Galvin) page 291
By these definitions, it is possible (easy even) to build a system
with virtual memory but no paging. Even I can do it.
-rob
The mapping can happen a number of ways. The two more
popular are via paging hardware or segmentation hardware.
Pages are typically fixed size and segments variable size.
From the PDP-11 to the MIPS there have been enough flavors
that the distinction is a bit blurred.
If one is willing to move data between a backing store and
main memory in addition to chaging the mappings, one can
make the main memory appear larger than it really is. This
is usually termed demand paging or demand segmentation.
An earlier technique, still in use in addition to demand paging/
segmentation is swapping. If many processes are running on
a particular system, it may desirable to swap in main memory
one for another to give the illusion of a main memory that can
hold all of them.
And of course there is the even earlier technique of overlays.
Here one figures out the execution tree of routines in a
program. One might note that routine A will never be an
ancestor of routine B or vice versa. THerefore, there's no
requirement that they live in memory simultaneously and can
occupy the same memory locations, just at different times.
>And of course there is the even earlier technique of overlays.
I wish you hadn't mentioned those. I'd almost managed to forget about them.
In addition, memory management units normally provide varying forms of
protection for pages (e.g., instructions are usually made read- or
execute-only) and checking for out-of-bounds (unmapped) addresses. On
many machines, notably the PC, a read from an address with no
corresponding memory (i.e., out-of-bounds) yields garbage; with memory
management on, many such references can be caught. The MMU can thus
be used to ensure that a program doesn't access data in other programs
(including the kernel) without their consent.
Another potential use of mapping is to avoid copying data by remapping
pages.
I would turn the question around: when would you want a one-to-one
mapping of virtual to physical addresses? There are a few such cases:
if memory serves, the old VAX 750 Plan 9 file server ran with the MMU
off because it runs no user-mode processes and it was found that
running with the MMU off made the machine run much faster.
> Another potential use of mapping is to avoid copying data by remapping
> pages.
Plan 9 has no DLLs. It has a C runtime library. I'm sure it's smaller
than the GNU C library, but is there a copy of the libary in every
executable in /bin?
is there a copy of it in every
process's memory or is it shared among all the processses?
if so, is memory mapping how the sharing is effected?
(I know this is undergrad material. Let me know if I should stop
asking elementary questions here.)
Sharing of instructions is done at the granularity of process text
segments, as in V6 or V7 Unix. The text segment of a process that
forks is shared between parent and child by page mapping. Also,
running (via exec) a program multiple times concurrently causes the
(pure) text segment to be shared by page mapping across those
processes. So all copies of rc and on a machine should share a text
segment.
Given that degree of sharing, the low cost of RAM, and the increase in
OS complexity, slowness and insecurity in the implementations of
dynamic libraries that I've seen, I don't see a need for dynamic
libraries. (Remember that the real impetus for adding them to Unix
was X11 and its big and badly-factored libraries, which most of us
aren't blessed with.) My terminal has 115 processes; all but 4 of
them share their text segment with at least one other process, usually
more. 74 of them are instances of rio, Mail, rc, acme, listen,
plumber and samterm. A CPU server has 141 processes; all but 2 share
text. 80 of them are listen, another 21 are rc, exportfs, kfs, dns
and consolefs. A quick sampling suggests that Plan 9 programs are
typically smaller than FreeBSD/386 programs even with shared
libraries. Here are some FreeBSD sizes:
: unix; size /bin/cat /bin/ed /usr/bin/awk /usr/X11/bin/sam
text data bss dec hex filename
54188 4324 9760 68272 10ab0 /bin/cat
122835 8772 81920 213527 34217 /bin/ed
135761 4772 15756 156289 26281 /usr/bin/awk
52525 1412 53448 107385 1a379 /usr/X11/bin/sam
Of those, awk and sam use shared libraries. The corresponding Plan 9
sizes are:
; cd /bin; size cat ed awk sam
15996t + 2208d + 944b = 19148 cat
45964t + 4212d + 41232b = 91408 ed
114731t + 35660d + 12040b = 162431 awk
86574t + 7800d + 66240b = 160614 sam
and the Plan 9 programs cope with Unicode and UTF.
it's a distinction that certainly used to be made when teaching operating systems.
Neither do I. Didn't the tests show that the implementation of them
on unix actually made things slower and more memory got used, not less?
Virtual memory usually refers to the management of the memory when you
allow more 'memory' to be used than you have physical memory. It always
implies a private virtual address space (unlike those Dragonball based
Palm things).
Hence you could have a private virtual address space but no virtual memory.
This would limit the size of the collection of processes on the machine to
not consume more that the amount of physical memory you had.
Once you have a private virtual address space [essential, except in certain
special cases] you can then manage the physical memory in any way you like.
Oh, if it comes to DLLs, those things are 'orrible; every 'process'
shares the DLL's data segment. That's one reason why it is impossible
to write a correct windows program.
> Thanks for that - it was a dumb question.
actually not a dumb question I think. There have been supercomputers with
no VM hardware that were built, and the OS on these remapped (relinked)
executables at program load time, so as to avoid the overhead that you get
with VM (basically a bunch of logic in the address path). So in essence
the start address in your code and the address of your data would be
unique for each execution of your program.
Some of the more fancy ones wrapped base and bounds registers around each
program, and that was as far as protection went.
ron
Could anyone recommend a good book to help me remedy my profound ignorance
of these matters? I'm looking for a conceptual overview, nothing too heavy,
rather than something that will actually teach me how to write an OS.
Andrey mentioned Silberschatz & Galvin - would that fit the bill?
I have an amateur question: how would that work? would the compilers
need to cooperate for this to work? How would something like a stray
pointer be handled?
I'm not sure if "no paging" means no hardware memory management of
any kind.
>
> >
> >By these definitions, it is possible (easy even) to build a system
> >with virtual memory but no paging. Even I can do it.
> >
> >-rob
>
> I have an amateur question: how would that work? would the compilers
> need to cooperate for this to work? How would something like a stray
> pointer be handled?
see any old burroughs stack machine. Or the i286. Compilers do not
necessarily need to cooperate.
> I'm not sure if "no paging" means no hardware memory management of
> any kind.
no, it just means no paging :-)
ron
Do you mean systems that had hardware like this memory bank switch:
http://home.swipnet.se/~w-68269/z80_mmu.pdf
>> I'm not sure if "no paging" means no hardware memory management of
>> any kind.
>
>no, it just means no paging :-)
>
>ron
I was confusing no-paging with no-hardware-mmu.
P.S. Would you believe that there is a memorymanagement.org, dedicated
to the subject?
> Given that degree of sharing, the low cost of RAM, and the increase in
> OS complexity, slowness and insecurity in the implementations of
> dynamic libraries that I've seen, I don't see a need for dynamic
> libraries.
Well, this sounds a little like "it's inherently buggy", which is
false. If you don't trust yourself to write a shared library
implementation correctly, then say so, but I think the Plan 9 authors
are certainly capable of writing one that works right.
There may be other reason to not want them--as I'm sure the Plan 9
authors have chosen. However, "we can't write an implementation
without bugs" is not a good reason.
Such a deal.
There is that, but the environment is so hostile it really is hard.
> Could anyone recommend a good book to help me remedy my profound ignorance
> of these matters? I'm looking for a conceptual overview, nothing too heavy,
> rather than something that will actually teach me how to write an OS.
> Andrey mentioned Silberschatz & Galvin - would that fit the bill?
When I were a lad, we used this:
Fundamentals of Operating Systems
By A. Lister
Hardcover
161 Pages
Edition: 3rd ed
Published by Springer-Verlag New York, Incorporated
Date Published: 09/1985
ISBN: 0387912517
At 161 pages it makes it a 'readable' size. The rest I picked up 'the hard way'
(tm) or from brucee or maltby.
Yeah, just put truss/strace on any shared libary binary. I assume
that all those mmap()s are to map the libraries in and each one of
those is a _system call_, plus all the stat/open's to find them.
It's a lot quicker (and simpler) in the kernel to get exec to do
the necessary.
A major drawback right now is that, unless we change
our MMU handling in a drastic way,
we have to run the shared library at the same addresses
in all programs. Might be a bit of a problem (unless we
go to 64 bit addressing). The current MMU
model with its lazy evaluation and no need for a
intermachine shootdown is quite elegant and I'm not sanguine
to lose it just for DLL's.
As Geoff states, we don't seem to be losing out by not
having them, vis a vis memory size. Some things would
be more efficiently done with a shared library, shared
databases for example. I'm just not yet prepared to
pay the price in increased complexity. Others may be.
> >see any old burroughs stack machine. Or the i286. Compilers do not
> >necessarily need to cooperate.
>
> Do you mean systems that had hardware like this memory bank switch:
>
> http://home.swipnet.se/~w-68269/z80_mmu.pdf
actually just about everybody did that one with the z80. Lots of
companies (HP, TI, etc.) used z80s in embedded service, and ca. 1981 began
to put in bank-switch schemes.
And no, the burroughs did not work like that at all.
ron
and in the worst case you'll end up where GNU is now, with symbol
versioning, 21 different versions of opendir in glibc, and so on an so on.
Watching a simple 'ls' do hundreds of symbol fixups is really
enlightening. Especially when so many of them are for the same symbol with
slight variations on the name. My simple, formerly working, libc-based
private name spaces are still totally hosed due to this nonsense.
ron
--
Richard Maxwell Underwood
The Internet Is Missing! http://www.satn.org/about/missinginternet.htm
What I just posted is an excerpt from
http://www.erasmatazz.com/library/Mind/How_to_Think_Uncluttering.html
At first it seems offtopic, till you realize that software
preferences often mirror cognitive styles. What is important about
Plan 9, IMO, is not how the software differs from other software, but
rather how people who prefer Plan 9 differ from people who prefer,
eg, Linux or Perl.
The quote I just posted was written by someone with a BS and MS in
physics. Physics definitely has that property that the people who
do it well are the ones who have a habit of searching for the handful of
important facts among the milliards.